FA Dev Tools

JSON Formatter

Paste JSON to pretty-print it with your chosen indent, or minify it onto a single line. Invalid JSON shows the parse error below.

Rejoins string values that a terminal or log viewer wrapped onto the next line, and escapes any other stray control characters. Line breaks between values are valid JSON and are left alone.

Instructions

Pretty-prints JSON so it is readable, or minifies it back down to one line.

  1. Paste JSON into the input — Paste pulls it straight from the clipboard.
  2. Choose Format and an indent (2 spaces, 4 spaces or tab), or Minify to strip all whitespace.
  3. Tick Auto-fix line breaks inside strings if the payload was copied out of a terminal or a log and a value is split across lines.
  4. The output updates as you type; Copy takes the result.

Tips

  • If the input will not parse, the parse error shows in red above the output — it names the position, which is usually a trailing comma or an unquoted key.
  • Auto-fix only runs after a normal parse has already failed, so valid JSON is never rewritten. It drops the line break so the value joins back up — a genuinely multi-line string is collapsed onto one line.
  • The Indent select is disabled while minifying — there is nothing to indent.
  • Hit Example and pick Format, Minify or Auto-fix to load a sample payload and see that action run.

About JSON formatting

What a JSON formatter is for

JSON (JavaScript Object Notation, defined in RFC 8259 and ECMA-404) is the usual format for API responses, config files, message queues and structured logs. Servers normally send it minified: one long line with no spaces, which is compact but very hard to read once objects are nested a few levels deep.

Formatting (also called pretty-printing or beautifying) parses the text and prints it again with one value per line and an indent for each level of nesting. Minifying does the opposite and removes every space and line break that is not inside a string. Minified JSON is smaller to send and fits on one line, which suits a log entry, an environment variable or a command-line argument.

Strict JSON rules that stop a parse

JSON is stricter than the JavaScript object literals it looks like. Keys and strings must use double quotes, never single quotes. There are no comments, no trailing comma after the last item, and no undefined, NaN or Infinity. The literals true, false and null must be lowercase. A single { name: 'x', } breaks three of these rules at once.

Files such as tsconfig.json or VS Code settings are really JSONC (JSON with comments), and some projects use JSON5, which also allows unquoted keys. This tool uses the standard parser built into your browser, so those extras are reported as errors. The error text comes from the browser and usually names the position of the first problem.

What can change when JSON is re-printed

The tool parses your JSON into values and prints them again, so the data stays the same but a few details of how it was written can change. Numbers are normalised: 1.0 becomes 1 and 1e3 becomes 1000. Escapes such as \u00e9 and \/ come out as the plain characters é and /. If a key appears twice in one object, only the last value is kept. Keys that are plain non-negative integers, such as "2" or "10", move to the front of their object in ascending order.

The one change that loses data is large integers. Browsers store JSON numbers as 64-bit floating point, which is exact only up to 9007199254740991 (2^53 − 1). A 64-bit database ID such as 12345678901234567890 comes back as 12345678901234567000. If your IDs are that long, keep them as strings in the JSON.

Indent options and auto-fix

Format offers 2 spaces, 4 spaces or a tab per level. The output updates as you type, and nothing is sent to a server: parsing and printing run in your browser.

JSON copied out of a terminal or a log viewer often has a long string value wrapped onto the next line. A raw line break inside a string is not allowed, so the whole document fails to parse. With Auto-fix line breaks inside strings ticked (the default), the tool first tries a normal parse. Only if that fails does it remove raw line breaks inside string values, turn a raw tab into \t and other control characters into \u escapes, then try again and tell you how many characters it fixed. Line breaks between values are valid JSON and are left alone. A string that was meant to span several lines is joined into one, so check the result if that matters.

Frequently asked questions

Why does my JSON say Unexpected token?
The parser met a character it did not expect at that position. The usual causes are a trailing comma, a single-quoted string, an unquoted key, a comment, or text such as a log prefix before the opening brace. Look just before the position the error names.
Can JSON have comments?
Not in standard JSON. RFC 8259 has no comment syntax, so a strict parser rejects // and /* */. JSONC and JSON5 allow comments, but you need to strip them before using a standard JSON parser like the one in this tool.
Why did a long number change after formatting?
JavaScript reads JSON numbers as double-precision floats, which hold integers exactly only up to 9,007,199,254,740,991. Longer integers, such as 64-bit IDs, are rounded. Send them as strings to keep every digit.