DNSfinder.net
JSON Tools

JSON Formatter & Validator

Paste JSON into the input box and the tool parses it as you type. Valid input is shown pretty-printed with 2 spaces, 4 spaces or tabs, or minified to a single line, and can be explored as a collapsible tree. Invalid input gets the line and column of the first syntax error, a plain description of it and a caret under the offending character. Parsing happens in your browser, so nothing you paste is uploaded.

Loading JSON Formatter & Validator...

Querying live edge resolvers and network infrastructure...

How to use the JSON Formatter & Validator

  1. Paste or type JSON into the Input box. A Valid JSON or Invalid badge appears above it straight away.
  2. If it is invalid, read the message under the box, go to the line and column it names, fix that character and repeat until the badge turns green.
  3. Choose Beautify with 2 spaces, 4 spaces or tabs, or Minify, and tick Sort keys if you want object keys in alphabetical order.
  4. Switch the output between Text and Tree, then use Copy or Download, which saves the result as formatted.json.

What to look for

Errors come with a position

The message names what the parser expected, for example Trailing comma before '}' or Expected a double-quoted property name, with the line and column where it stopped. The line is printed underneath with a caret at that column. Only the first error is reported, so fix it and look again.

The tree shows structure

Tree view draws each object and array as a collapsible row with its size, {5} for five keys or [3] for three items. The first two levels start open and deeper ones start closed. Keys, strings, numbers and the literals true, false and null each get their own colour.

Counts under the output

Pills below the output give the number of objects and arrays, the total of keys across all objects, the nesting depth and the size of the output in bytes. Toggle Minify and watch the byte count: the built-in sample drops from 166 bytes to 112.

Guide

JSON syntax rules and the errors that break them

What valid JSON looks like

JSON is defined by RFC 8259 and has six kinds of value: objects in braces, arrays in square brackets, strings, numbers, booleans and null. Object keys must be strings in double quotes, strings may only use double quotes, and items are separated by commas with none after the last. A document is a single value, usually an object or an array, though a bare number or string is valid too and this tool accepts it.

The format is stricter than the JavaScript it came from. Comments are not allowed. Numbers cannot have leading zeros, a plus sign in front or a bare decimal point. Inside a string, a line break or tab must be written as an escape such as \n or \t, and a backslash may only be followed by a double quote, another backslash, a slash, one of the letters b, f, n, r or t, or u plus four hex digits.

Reading the error message

When parsing fails, the tool runs its own scanner over the text to find the exact position, because browsers do not reliably say where a JSON error is. The result is a line and column counted from 1, a message, and the source line with a caret under the column. The position is where the parser gave up, which is sometimes just after the real mistake: a missing comma is reported at the start of the next item.

Unexpected followed by a character usually points at a word JSON does not have. Python's True, False and None, JavaScript's undefined and NaN, and unquoted text all end up here. The fix is the JSON spelling (true, false, null) or a pair of double quotes.

  • Trailing comma before '}' or ']': delete the comma after the last item.
  • Expected a double-quoted property name: a key is unquoted or in single quotes.
  • Expected ',' or '}' after property value: a comma is missing, or a comment follows the value.
  • Unescaped control character in string: a raw line break or tab sits inside quotes.
  • Unexpected content after the JSON value: two documents were pasted together.

Beautify, minify and sort

Beautify writes the parsed value out with one key or item per line and the indentation you chose. Minify removes every optional space and line break, which is the form to send over a network or store in a database column. Both hold the same data. Only whitespace differs.

Sort keys orders the keys of every object alphabetically, at every depth, and leaves arrays alone because array order carries meaning. Sorting is by character code, so capital letters come before lower-case ones. It makes two versions of a config or API response line up for a diff, since objects that differ only in key order become identical text.

What reformatting changes in your data

The output is not the input with new spacing. It is the parsed value written out again by the browser's JSON serialiser. For most documents the difference is invisible, but a few things change. Whole numbers beyond 9007199254740991 lose precision, so 9007199254740993 comes back as 9007199254740992. 1.0 becomes 1 and 1e3 becomes 1000. A duplicated key keeps only its last value.

Escapes are normalised as well: \u00e9 is written out as the accented letter itself and \/ as a plain slash. Keys that look like non-negative integers move to the front of their object in numeric order, a rule of JavaScript objects that applies even with Sort keys off. If 64-bit IDs must survive exactly, they have to be strings in the source data.

Limits and related tools

The tool checks syntax only. It does not validate against a JSON Schema, does not accept JSON5 or JSON with comments, and does not repair broken input for you. There is no size cap in the code, but the document is parsed again on every keystroke, so a very large file is easier to paste once than to edit in place.

To decode a Base64 payload before formatting it, such as the middle section of a JWT, use Base64 Encoder / Decoder with the URL-safe option. To compare two files by checksum instead of by eye, MD5 Generator hashes both text and files.

Knowledge Base & FAQ

JSON Formatter & Validator FAQs

Common questions about the json formatter & validator.

The usual culprits are a trailing comma after the last item, single quotes instead of double quotes, unquoted property names, comments, and raw line breaks inside strings. All of these are legal in JavaScript object literals and illegal in JSON. Paste the text and the error box gives the line, the column and the rule that was broken.