JSON Formatter
Paste JSON from an API response, config file, webhook, or log sample, then choose Format, Minify, or Validate. The formatter expands nested objects and arrays with 2 or 4 spaces, the minifier removes unnecessary whitespace, and the validator checks that the text is valid JSON before you copy the result.
How to format JSON
-
1
Paste your JSON
Add a complete JSON value: an object, array, string, number, boolean, or `null`.
-
2
Choose an action
Use Format for readable output, Minify for compact output, or Validate for a syntax check.
-
3
Pick indentation
For formatted output, choose 2 spaces for web projects or 4 spaces when that matches your repository style.
-
4
Copy the result
Review the parser message or formatted output, then copy the result back into your editor, API client, or documentation.
What this JSON formatter does
- Format JSON: turns compact input such as
{"a":1,"b":[1,2,3]}into readable, indented JSON. - Minify JSON: removes whitespace that is only there for readability, useful for compact examples, embeds, and transport payloads.
- Validate syntax: checks whether the pasted text can be parsed as JSON. This is a syntax check, not a JSON Schema validation.
- Handle any JSON root value: objects and arrays are common, but a JSON text may also be a string, number,
true,false, ornull. - Keep the workflow simple: paste, choose the action, review the output, and copy the result.
What it intentionally does not change
- It does not repair malformed JSON automatically. The parser message tells you what to fix.
- It does not accept JSONP wrappers such as
callback({...}). - It does not accept comments or trailing commas from JSONC unless you remove them first.
- It does not sort object keys. Existing key order is preserved as much as the parser and serializer allow.
- It does not validate business rules, required fields, or API schemas. Use a JSON Schema validator for that step.
Formatting choices
| Situation | Best action | Why it helps |
|---|---|---|
| Reading an API response | Format with 2 spaces | Nested objects and arrays become easier to scan. |
| Matching a repository style | Format with 2 or 4 spaces | Consistent indentation keeps code reviews clean. |
| Embedding a payload in a request | Minify | Removes whitespace without changing the JSON values. |
| Checking copied data from logs | Validate | Confirms the pasted fragment is complete JSON before you reuse it. |
| Preparing API documentation | Format | Examples are easier for readers to inspect and copy. |
JSON syntax issues this catches
| Parser complaint | Common cause | What to do |
|---|---|---|
Unexpected token ' at position X |
Single quotes around a key or string | Use double quotes for JSON strings. |
Unexpected end of JSON input |
Missing closing brace, bracket, or quote | Check the end of the pasted text. |
Unexpected token , at position X |
Trailing comma after the last item | Remove the trailing comma. |
Unexpected token a at position X |
Unquoted key, NaN, or undefined |
Quote keys and use valid JSON values only. |
Unexpected token / at position X |
Comment copied from JSONC or JavaScript | Remove // and /* */ comments before validating. |
Practical tips
- Format first when reviewing a response, then minify only when a compact payload is actually needed.
- Validate before pasting JSON into docs, tickets, or API clients, especially when the source was a partial log line.
- Keep indentation consistent with the surrounding project. Changing 2 spaces to 4 spaces across an existing file can create a noisy diff.
- Avoid pasting secrets, production credentials, or customer data into any general-purpose web tool. Use your organization’s approved offline or internal formatter for sensitive payloads.
Frequently Asked Questions
No. This tool checks JSON syntax only. If you need to confirm required fields, allowed values, or object shapes, run the result through a JSON Schema validator after it parses cleanly.
Strict JSON does not allow comments or trailing commas. Remove JSONC-style comments and final commas before validating or formatting.
Use the style your project already uses. Two spaces are common in JavaScript and web configuration files; four spaces can be easier to read in some backend repositories.
Avoid pasting secrets, access tokens, credentials, or customer records into a general-purpose web formatter. For sensitive payloads, use an approved internal or offline tool.
Related Tools
HEX Color Picker
Pick any colour visually and get its HEX, RGB, HSL, HSV and CMYK values, plus accessibility contrast against white and black.
Color Palette Generator
Generate monochromatic, analogous, complementary, triadic or tetradic color palettes from a base HEX color and export copy-ready CSS variables.
FPS Counter
Measure browser FPS with requestAnimationFrame, smoothing, min/max frame rate, warnings and an optional graph. Runs locally with no upload or API.
BBCode to HTML Converter
Convert BBCode (bulletin-board markup) to clean HTML. Handles formatting tags, lists, quotes, code, images, links and tables.
Random Color Palette Generator
Generate random color palettes from 2 to 15 swatches, choose a vibrant, pastel, muted or dark style, then copy HEX codes or CSS variables.
Binary to ASCII Converter
Paste binary (space-separated bytes or a long bitstream) and get the ASCII text it represents. Handles 7-bit and 8-bit encodings.