Json Formatter
Paste your JSON to instantly format, validate, and minify it, right in your browser.
What does this JSON Formatter do?
This tool takes messy, minified, or hard-to-read JSON and turns it into a clean, properly indented structure you can actually work with. Paste or type JSON into the input panel and the tool checks it as you type, marking it valid or invalid with a status dot so you know immediately whether the structure is sound.
Click Format to pretty-print the JSON with two-space indentation and color-coded syntax highlighting for keys, strings, numbers, booleans, and null values, complete with line numbers on both panels. If you need the opposite, Minify strips out all the extra whitespace and line breaks to produce the smallest possible version of the same data. The formatted or minified result can be copied to your clipboard in one click or downloaded as a standalone .json file, and everything runs directly in your browser, so nothing you paste is ever sent to a server.
How to Use This JSON Formatter?
- Paste or type your JSON. Drop your data into the Input panel on the left. The character and line count update automatically as you type.
- Watch the status dot. A green dot next to the input panel means your JSON is valid right now; a red, pulsing dot means something is broken, and the exact parser error appears just below the box.
- Click Format (or press Ctrl+Enter). The tool re-indents your JSON with two-space spacing and highlights it by type, showing line numbers alongside the result.
- Or click Minify instead. This collapses the same JSON into a single compact line with no unnecessary whitespace, useful when file size matters more than readability.
- Copy or download the output. Use Copy Output to grab the formatted or minified result, or Download to save it as a .json file named with a timestamp.
- Clear or load a sample. Use Clear to wipe both panels and start fresh, or click Sample to instantly load an example JSON object and see the tool in action.
Built-In Features
Real-Time Validation
As you type, the input is checked in the background and a status dot turns green or red so you can spot a broken structure before you even hit Format.
Exact Error Messages
Invalid JSON doesn’t just get flagged, it shows the specific parser error so you know exactly what to fix and roughly where the problem sits in your JSON code.
Syntax Highlighting
Keys, string values, numbers, booleans, and null are each given their own color in the output, making it much faster to scan a large object.
Line Numbers
Both the input and the formatted output display line numbers, which makes it easier to reference a specific line when debugging with a teammate.
One-Click Copy & Download
Grab the formatted or minified result instantly with Copy Output, or save it straight to your device as a .json file with Download.
Keyboard-Friendly Editing
Press Ctrl+Enter to format without touching the mouse, and Tab inside the input inserts a proper two-space indent instead of jumping focus away.
How Formatting and Validation Work
Both features are built on the same underlying check, they just present the result differently. Understanding the two paths makes it easier to know what to expect from each button.
Format
Your input is parsed and then rebuilt with consistent two-space indentation, so nested objects and arrays are visually easy to trace. Every value gets highlighted by type at the same time, and a line-number gutter is generated to match.
Validate
Every keystroke is checked on a short delay so the tool isn’t re-parsing on every single character. If the structure parses cleanly, the dot turns green; if it fails, the dot turns red and the parser’s own error message is shown so you know what to correct.
Minify uses the same parsing step as Format and Validate, it simply skips the indentation so the result comes out as one continuous line with no line breaks or extra spaces.
Format or Minify: Which One Do You Need?
Both modes start from the same valid JSON, they just serve different purposes depending on whether a human or a machine is reading the result next.
| Situation | Recommended Mode | Why |
|---|---|---|
| Reading an API response | Format | Indentation and highlighting make nested fields easy to scan |
| Debugging a config file | Format | Line numbers make it simple to point a teammate to the exact spot |
| Sending a payload to production | Minify | Removes whitespace so the request body stays as small as possible |
| Storing JSON in a database column | Minify | Compact strings save storage space and transfer faster |
| Checking whether JSON is valid | Either | The status dot validates the input before you choose a mode |
Common Reasons to Format or Validate JSON
Debugging API Responses
Paste a raw response straight from a browser console or an API client and format it so you can quickly find the exact field that’s missing or wrong in seconds.
Cleaning Up Config Files
package.json, tsconfig files, and other JSON-based configs that have been edited by hand often end up unevenly indented. Formatting resets that in one click.
Checking Data Before You Ship It
Run a quick validation pass on hand-written JSON before it goes into a request body, a test fixture, or a database seed file.
Shrinking Payloads Before Sending
Minify a large JSON object down to a single line so it stays lightweight when it’s copied into a request, a script, or an environment variable.
Common JSON Syntax Errors and How to Fix Them
Most invalid JSON comes down to a small handful of recurring mistakes. When the status dot turns red, the error message shown below the input panel usually matches one of these patterns.
| Typical Error | Common Cause | How to Fix It |
|---|---|---|
| Unexpected token } or ] | A trailing comma left after the last item in an object or array | Remove the comma right before the closing bracket |
| Unexpected token in JSON at position 0 | A value isn’t wrapped in quotes, or the input is empty | Wrap string values in double quotes and make sure something was pasted in |
| Unexpected string in JSON | A comma is missing between two entries | Add a comma to separate the two values |
| Unexpected end of JSON input | An opening bracket or brace, like { or [, was never closed | Check that every opening bracket has a matching closing bracket |
| Bad control character in string literal | A raw line break or tab was pasted inside a quoted string | Remove the line break or escape it as \n within the string |
| Unexpected token ‘ | Single quotes were used instead of double quotes around a key or string | Replace single quotes with double quotes throughout |
What Counts as Valid JSON?
JSON follows a strict, fairly small set of rules. Knowing them makes it much faster to spot why a piece of data won’t validate.
Double Quotes Only
Every key and every string value must be wrapped in double quotes. Single quotes and unquoted keys, both common in JavaScript objects, are not valid JSON.
No Trailing Commas
The last item in an object or an array can’t be followed by a comma. This is one of the most common reasons well-formatted-looking JSON still fails to validate.
Numbers Follow Strict Rules
Numbers can’t have leading zeros, can’t start with a plus sign, and can’t be written as NaN or Infinity. Decimals need at least one digit on both sides of the point.
Only Six Value Types
Every value in JSON has to be an object, an array, a string, a number, a boolean, or null. Anything else, such as a function or a date object, isn’t valid on its own.
Useful Tips
Read the Error Message Closely
The red status message names the exact issue the parser hit, such as an unexpected character or a missing comma, so start there instead of scanning the whole file line by line.
Use the Keyboard Shortcut
Once your JSON is pasted in, hitting Ctrl+Enter formats it right away without reaching for the mouse, which is handy when you’re moving between several snippets.
Validating Values Inside Strings
This tool confirms your overall JSON structure is valid, but it doesn’t check the content of individual string values. If a field needs to match a specific pattern, like an email or a date format, our Regex Tester is a better fit for checking that.
Try It With the Sample First
New to the tool? Click Sample to load a small example object and immediately see how formatting, highlighting, and line numbers look before pasting in your own data or JSON for quick, easy testing.
Frequently Asked Questions
How do I format JSON online?
Paste or type your JSON into the input panel and click Format, or press Ctrl+Enter. The tool re-indents the structure with two-space spacing and highlights it by value type.
Is this JSON formatter free to use?
Yes. The tool is free, requires no account, and runs directly in your browser.
How can I check if my JSON is valid?
Just start typing or pasting into the input panel. A status dot next to the panel turns green for valid JSON and red for invalid JSON, and an error message appears explaining what’s wrong when it’s invalid.
What does Minify do?
Minify removes all unnecessary whitespace and line breaks from valid JSON, compressing it into the smallest possible single-line version of the same data.
Can I download the formatted JSON as a file?
Yes. Click Download after formatting or minifying, and the current output is saved to your device as a .json file.
Why does the tool say my JSON is invalid?
This usually means there’s a syntax problem, such as a trailing comma, a missing quote, or an unclosed bracket. The message shown below the input panel comes directly from the parser and points to the specific issue.
What indentation does the Format button use?
Formatted output always uses two-space indentation for each nested level, which keeps the structure readable without spreading it out too wide.
Does this tool support very large JSON files?
The tool handles typical API responses and config files well. Extremely large documents may take a moment longer to validate and render since everything is processed in your browser.
Is my JSON data uploaded anywhere?
No. Everything you paste is parsed and formatted locally in your browser. Nothing is sent to a server or stored.
Can I copy the output without downloading it?
Yes. Click Copy Output to copy the current formatted or minified result straight to your clipboard.
Is there a keyboard shortcut for formatting?
Yes. Pressing Ctrl+Enter while the input panel is focused triggers the Format action, the same as clicking the Format button.
Can I see how much smaller minifying makes my JSON?
Yes. The footer shows the input size, the output size, and the percentage difference between them after you format or minify.
What’s the difference between Format and Validate?
Validation happens automatically as you type and only checks whether the structure is correct. Format takes that same valid structure and rewrites it with indentation, line numbers, and syntax highlighting.
Does this tool work on mobile devices?
Yes. The layout adjusts for smaller screens so you can paste, format, and copy JSON from a phone or tablet browser.
