JSON Formatter & Validator: Pretty Print, Minify
Paste JSON from an API response, config file or log to pretty-print it with 2-space indentation, minify it to a single line, or validate it against the RFC 8259 standard. When it is invalid, the error points to the line and position, so you can fix the usual suspects (a trailing comma, single quotes, an unquoted key) without reading the whole document.
Built by Jose Hunt · Checked 20 Nov 2026
How to use
Paste JSON into the input area, then choose Format, Minify, or Validate.
Powered by System.Text.Json (RFC 8259).
- check_circle Pretty-print with indentation
- check_circle Minify to compact form
- check_circle Validate, with the line and position of the first error
What is a JSON Formatter?
A JSON formatter takes JSON text and lays it out so people can read it, or packs it into one line so it takes less space. This one has three buttons. Format adds line breaks and a 2-space indent. Minify removes every space and line break that isn't inside a string. Validate only checks the syntax and tells you where the first error is.
JSON is defined by RFC 8259, and it's stricter than the JavaScript it looks like. Trailing commas, comments, single quotes, unquoted keys, NaN and Infinity are all invalid, and the validator rejects every one of them.
It checks syntax, not meaning. JSON with a missing field, a number sent as a string or the wrong nesting is still valid JSON, and this tool won't flag it. For that you need a schema check against the structure your code expects.
Your JSON is parsed on our server with Microsoft's System.Text.Json library. It isn't stored, and no AI is involved. For what each kind of error means and how to fix it, see "Unexpected token" and 5 other JSON errors. To pull values out of text that isn't JSON, try the Regex Tester.
When should you use it?
- check_circle Reading a minified API response or webhook payload while you debug
- check_circle Finding the line that breaks a config file before you deploy it
- check_circle Minifying a JSON fixture before pasting it into a test or an environment variable
- check_circle Checking what an API really returned when your code throws "Unexpected token <"
Example outputs
How it works
Every button starts the same way: the tool parses your input with JsonDocument.Parse from .NET's System.Text.Json, using the default options. If parsing fails, you see the library's own error message. If it succeeds, Format writes the document back out with a 2-space indent and Minify writes it back with no whitespace at all. Validate stops after the parse and shows Valid JSON.
Error positions count from zero. "LineNumber: 2 | BytePositionInLine: 6" means the third line, seventh byte (Microsoft Learn: LineNumber, BytePositionInLine). The position is counted in bytes, not characters, so an accented letter or an emoji earlier on the line pushes it further along than the column your editor shows.
The parser stops at the first problem and reports where it noticed it. That's often one token after the real mistake. A trailing comma is reported at the closing bracket, not at the comma, which matches what browsers report.
The default options are strict. Comments, trailing commas, single-quoted strings, unquoted keys, NaN, Infinity, undefined and Python's True and None are all errors, as RFC 8259 requires. Nesting deeper than 64 levels is rejected (Microsoft Learn). Duplicate keys are accepted and both are kept, because the RFC says names SHOULD be unique but doesn't forbid repeats.
Numbers are copied exactly as you typed them. 1.50 stays 1.50 and a 20-digit integer isn't rounded. Strings are not: on output, the library's default encoder writes every character outside basic ASCII, and HTML-sensitive characters such as < and >, as \u escapes (Microsoft Learn). Café comes out as Caf\u00E9. Any JSON parser reads it back as the same text, but it looks different.
Size is limited by how the page talks to our server. The text box sends its whole content each time it changes, as one message, and the site accepts messages up to 512 KB (the SignalR default is 32 KB, per Microsoft Learn). Quotes, backslashes and line breaks take extra room in that message, so the practical limit for pasted JSON is a little under 512 KB. Larger messages are rejected and the page loses its connection.
Tips for better results
- tips_and_updates Add 1 to the LineNumber in an error to get the line number your editor shows.
- tips_and_updates When an error points at a line, check the end of the line before it as well. Trailing and missing commas are reported one token after the mistake.
- tips_and_updates If Validate says '<' is an invalid start of a value at position 0, you pasted HTML, usually an error or login page, not JSON. Look at the request that produced it.
- tips_and_updates Double the backslashes in Windows paths. "C:\\data\\file" is what you want; "C:\new\file" passes validation because \n and \f are valid escapes, but the value then contains a line break.