UTILYARD
tools / developer

JSON Formatter

Format, validate, and minify JSON data.

INPUT
OUTPUT
output appears here...

About JSON Formatter

JSON (JavaScript Object Notation) is a lightweight data-interchange format. This tool formats raw JSON into readable indented output, validates syntax, and can minify it for production use. All processing happens in your browser — nothing is sent to a server.

FAQ

Is my data sent to a server?
No. All processing happens locally in your browser.
What indent options are available?
2 spaces, 4 spaces, or tab indentation.
What does Minify do?
Removes all whitespace and newlines for the most compact JSON representation.
Can I format invalid JSON?
No. The input must be valid JSON. The Validate button will show the exact error and location.

ABOUT THIS TOOL

Paste raw JSON to instantly format it with proper indentation, validate its syntax, or collapse it back into a compact single line. Beyond basic pretty-printing, the formatter flags syntax errors like trailing commas, unquoted keys, or mismatched brackets that break strict JSON parsers, and points to roughly where the problem is. Minifying strips whitespace to shrink payloads before sending them over the wire, while indenting turns a single-line API response into something you can actually read and diff. Developers use it to debug API responses, config files, or any JSON data that arrives as an unreadable wall of text — all processing happens locally in the browser, nothing is uploaded.

HOW TO USE

  1. Paste or type your JSON into the input panel.
  2. Click "Format" to pretty-print it with indentation, or "Minify" to collapse it to one line.
  3. Check the error message if the JSON is invalid — it points to the line or character causing the problem.
  4. Adjust indentation width (2 or 4 spaces) if the tool offers that option.
  5. Copy the formatted or minified result with the copy button.
  6. Use the cleaned-up JSON in your code, API testing tool, or config file.

COMMON USE CASES

  • A backend developer pastes in a minified API response to read nested objects before writing a parser.
  • A frontend engineer debugging a 500 error checks whether a request body sent to an endpoint is actually valid JSON.
  • Someone editing a package.json or tsconfig.json by hand wants to catch a missing comma before committing.
  • A QA tester minifies a large JSON fixture file to reduce its size for a test payload.
  • A student learning APIs uses it to understand the structure of a JSON response returned by a public API.

TIPS & COMMON MISTAKES

  • JSON does not allow trailing commas, comments, or single quotes — even though JavaScript object literals do, so copy-pasted JS objects often fail validation until cleaned up.
  • Very large JSON files (multi-MB) can be slow to format in-browser; minify first if you just need to shrink size.
  • Keys must always be double-quoted strings; numbers, booleans, null, arrays, and objects are the only other valid value types.
  • If validation fails, check for a stray trailing comma after the last item in an array or object — it's the most common cause of "unexpected token" errors.

MORE QUESTIONS

Why does my JSON fail to validate even though it looks correct?
The most common causes are trailing commas after the last array/object item, single quotes instead of double quotes, or unquoted object keys — all valid in JavaScript but not in strict JSON per the JSON spec (RFC 8259).
What's the difference between minifying and formatting?
Formatting adds indentation and line breaks for readability; minifying strips all non-essential whitespace to reduce file size, which matters when JSON is sent over a network or embedded in a URL.
Can JSON contain comments?
No. The JSON specification has no comment syntax, so any // or /* */ comments will cause a parse error — a common problem when copying from JSONC or JS config files.
Is my data sent to a server when I use this tool?
No, formatting and validation happen entirely in your browser using JavaScript's built-in JSON parser, so nothing you paste leaves your machine.

RELATED GUIDES

What is JSON?
A complete guide to JSON syntax, data types, and common use cases.
Read →
What is an API?
What APIs are, how REST works, what HTTP methods and status codes mean, and how to make a basic API request in JavaScript.
Read →
JSON Formatter — UtilYard