Xing is crossing, step by step

JavaScript

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.

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:

char: any-Unicode-character-except-“-or-\-or-control-character

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/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.

Feedback

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!