We’re thrilled to launch LintJSON, a web tool for developers to easily validate, format and minify JSON string. Even more, it can be used to fix invalid JSON string which is broken by newline or tab.
Why we build LintJSON
There’re already couple sites that can format JSON, why would we create another wheel then?
The answer is we want a better one which is faster and user-friendly: the user should see the result right after input without scrolling down the page. Furthermore, it would be great if some invalid JSON can be fixed by a tool, rather than tedious human work.
What features it provides
Basically, it provides 2 features: formats and minifies JSON. Plus, we can fix invalid JSON which is broken by newline or tab.
First, let’s talk about these 2 basic features: format and minify. Actually, they’re both pretty print work. Validation is enforced before pretty print work. An option is offered to let the user choose indentation type.
After validation passed, the formatted result will be shown in the input area.
Here comes the minify result.
If validation failed, an error message indicating which line is wrong will be shown in result area.
After the basic features, here comes the advanced function: fix invalid JSON which is broken by newline or tab in JSON ‘string’ type element. But wait, is newline or tab invalid in JSON? Yes, it’s invalid in JSON’s ‘string’ type. According to JSON official site:
A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.
And the definition for ‘char’ in JSON string:
Since newline and tab are both control-character, so they’re invalid in JSON ‘string’ type. Either we want to remove or escape them. But it’s very hard for the human being to detect and fix. The following image shows a broken JSON with a newline in the second key.
The fix-broken-JSON feature will be triggered if there’s newline or tab in input JSON ‘string’ type.
A popup window will jump out and ask what the user would like to do: remove, escape or ignore those invalid char. Let’s say ‘escape’ is clicked, then we’ll see something like the following image. Note the escaped ‘\n’ in “May world \nbe pease”.
- 2017/11/25 Add popup window to let the user select whether to remove, escape or ignore invalid newline/tab in JSON string element; Add indent select to let the user choose indent options (2 Space/3 Space/4 Space/Tab).
- 2017/11/13 Fix bug that input area overlap with the fake gutter in ATF.
- 2017/11/12 Make page load faster by building ATF (Above The Fold) first.
- 2017/10/22 Minor fix, like compress logo.png to < 3KB, adjust description text.
- 2017/10/21 Add support to fix invalid JSON broken by newline/tab; Optimize load speed by init CodeMirror directly in HTML rather than in js.
- 2017/10/10 Release new layout and color schema.
As we strive to keep improving LintJSON, we want to hear from you! Any suggestion or feedback is appreciated. Please leave a comment on this page if you want anything better from LintJSON. Thanks in advance!