Developer
JSON Formatter
Pretty-print JSON with 2 or 4 spaces, or minify it to one line. Invalid JSON is reported and the previous result is cleared. Copy the output locally.
Ready to run.
Formatted JSON
—
Output actions
Ready to copy output once your result appears.
Two-space, four-space, or one-line JSON
JSON Formatter parses with JSON.parse and prints with JSON.stringify. Format mode is selected at open, and the indent menu starts at 2 spaces. Minify mode stringifies with no gap. The menu entry labeled as a tab passes the number 1, so that choice is a single space, not a tab character. Invalid JSON clears the result.
How to format JSON
- 1Paste into JSON input. Press Format, or press Minify. The indent menu is visible only while Format is selected. It lists 2 spaces, 4 spaces, and 1 tab (\t).
- 2Press Run. Format writes JSON.stringify(value, null, indent). Minify writes JSON.stringify(value) with no space argument. The status reads Formatted successfully. or Minified successfully.
- 3Press Copy output. Changing indent or mode does not recompute until you press Run again. This tool does not offer download.
What it is good for
- • Making a one-line payload readable with two or four spaces.
- • Stripping indentation when you need the compact form JSON.stringify produces.
- • Seeing the parser message when a comma, quote, or comment makes the text illegal.
Example
Input
{"title":"Toolbench","status":"ready"}Output
{
"title": "Toolbench",
"status": "ready"
}Format mode with the default 2 spaces. Key order is the order JSON.parse stored. The space after each colon is inserted by JSON.stringify.
What the indent menu actually passes
The select is shown only in Format mode. Its options are 2 spaces with value 2, 4 spaces with value 4, and a third option whose visible label is 1 tab (\t) and whose value is the number 1. JSON.stringify treats a numeric space argument as that many space characters, capped by the engine at ten. The third option therefore indents with one space. It does not insert a tab, despite the label. Four spaces produce a wider block of the same object. Minify hides the select and passes no space argument, so the sample object becomes {"title":"Toolbench","status":"ready"} with no gap after the colon or the comma.
Run is required after every change. Picking 4 spaces, or pressing Minify, leaves the previous panel in place until the click. A successful click replaces the panel and publishes that string to Copy output. Before the first success, Copy output has nothing stored.
What JSON.parse accepts
The parser accepts objects, arrays, strings, numbers, true, false, and null. It accepts leading whitespace. It rejects comments, single-quoted strings, and trailing commas. A failure clears the panel to empty and sets the status to Invalid JSON: followed by the parser's own message, including a position when the engine provides one. The previous pretty text does not stay on screen after a failure.
Duplicate keys keep the last value, which is ordinary JSON.parse behavior. Key order in the output is the order the parser recorded. Numbers stay IEEE-754 values, so a very large integer can change when it is parsed and written back. The page does not preserve the original spacing, and it does not sort keys. undefined cannot appear in the input because it is not JSON.
Jobs before a conversion or a diff
A minified API body is hard to split by eye. Format it here, then copy the array or object you actually need. The guide Convert nested JSON to CSV without losing fields starts from a JSON array of records. Pretty-printing does not flatten nested objects. That conversion is a separate step on JSON to CSV. Two payloads that should be compared belong on JSON compare, which diffs structure rather than indent.
YAML documents are not parsed here. If the source is YAML, convert it on the YAML ↔ JSON converter first. That converter's JSON output is already two-space indented. You would use this formatter afterward only to switch to four spaces or to minify. This page will not drop YAML comments, because it never sees them. It also will not repair a file that is almost JSON.
Empty input, minify, and the tab label
An empty field fails JSON.parse. The status is the Invalid JSON prefix plus the engine message, and the result is cleared. The word null, the word true, and a bare number are legal JSON and will format. An empty object formats as {} even in Format mode, because there is nothing to indent. An empty array formats as [].
Do not expect the third menu entry to emit a tab character. If you copy the one-space result into a file, the indent bytes are U+0020. If you need a tab, this control will not produce one. Minify is the opposite extreme: one line, no added spaces, still valid JSON. There is no download button beside Copy output.
Rules and limitations
Format calls JSON.stringify with 2, 4, or 1. The value 1 is one space, even though the option label says tab. Minify calls JSON.stringify with no space argument. Both paths require the text to parse.
Comments, trailing commas, and single quotes fail and clear the result. Mode and indent changes apply on the next Run. There is no download, no key sort, and no YAML parser.
Common problems
If the indent looks like a single space, the menu is on the option labeled 1 tab (\t). Choose 2 spaces or 4 spaces and press Run again.
If the panel goes blank, the status begins with Invalid JSON:. The previous format is not kept. Fix the text and press Run.
Frequently asked questions
Does the tab option insert a tab?
No. That option's value is the number 1. JSON.stringify uses one space per level. The label reads 1 tab (\t), but the bytes are spaces.
What does minify remove?
It reprints the value with JSON.stringify and no space argument. The sample object becomes {"title":"Toolbench","status":"ready"}. Insignificant space is gone. String contents are unchanged.
Are comments allowed?
No. JSON.parse rejects comments and trailing commas. The result is cleared and the status starts with Invalid JSON: followed by the parser message.
Will key order change?
The formatter does not sort keys. Order matches what JSON.parse recorded from the text. Duplicate keys keep the last value.
Is my input uploaded or saved?
This tool processes input in your browser and does not save its input or output to local storage. Copy and download are user actions. The site uses analytics for page and action metadata and may use ads and production error reporting; see the Privacy Policy for those services.
About this tool
Maintained by Toolbench. For large or deeply nested files, split the input into smaller batches and verify representative results before using them in an import or application. Report reproducible problems through Contact.
Guides
- Convert nested JSON to CSV without losing fields
Choose between flattened columns and JSON cells, preserve arrays and review missing values before exporting.
Next steps
Related tools
Continue the workflow with nearby tools for formatting, publishing, debugging, or follow-up checks.
JSON Compare Online
Compare two JSON values and list added, removed, and changed paths.
Open JSON Compare OnlineYAML ↔ JSON Converter
Convert JSON to 2-space YAML, or YAML maps and lists to JSON.
Open YAML ↔ JSON ConverterJSON to CSV
Convert a JSON array of objects to CSV.
Open JSON to CSVCSV to JSON
Convert CSV data to a JSON array of objects.
Open CSV to JSONTrust
Policies, contact, and answers
Clear pages for how Toolbench works, what we collect, and how to reach us.