Trexmi
Developer Ready

JSON Formatter

Format, beautify or minify JSON online with 2-space, 4-space or tab indentation, optional recursive key sorting, validation, and copy-ready output.

Validate JSON before formatting Beautify JSON with 2 spaces, 4 spaces or tabs Minify JSON Sort object keys recursively while preserving array order
Supported input

Paste raw JSON copied from an API response or configuration file.

Tips

Start with the example, then replace it with your complete source.

Formatting preserves JSON values and array order. Sorting changes object-key order only.
INPUT Paste JSON *
0 chars0 words0 lines
Paste raw JSON copied from an API response or configuration file. Example: { "name": "John", "active": true }

Tool settings

Ctrl / ⌘ + Enter
Formatted JSON Validated JSON output. Use Format for readable JSON or Minify for compact JSON.
About the tool

What JSON Formatter does

JSON Formatter turns compact or inconsistently indented JSON into readable, validated output. Paste an API response, configuration object or data payload and choose 2 spaces, 4 spaces or tabs. You can also minify the document or sort object keys alphabetically.

The formatter parses the source as JSON before producing output. Invalid JSON is rejected instead of being silently rewritten. Values, arrays, numbers, booleans and null values are preserved; optional key sorting changes object-key order only.

This is useful for debugging REST responses, reviewing configuration, preparing examples for documentation, normalizing fixtures and making nested data easier to compare.

How to use

  1. Paste JSON. Include the complete document, including its opening and closing braces or brackets.
  2. Choose output. Select Format / Beautify or Minify.
  3. Set indentation. Choose 2 spaces, 4 spaces or tabs for formatted output.
  4. Sort if needed. Optional A–Z sorting applies recursively to object keys but leaves array order unchanged.
  5. Run and copy. Invalid input is rejected; valid JSON is returned as copy-ready output.
Built for the task

Why use JSON Formatter?

Focused controls, predictable output, and a workflow designed around this exact transformation.

01

Validation before output

The formatter parses the document before returning formatted or minified JSON.

02

Flexible indentation

Choose 2 spaces, 4 spaces or tabs to match project style.

03

Recursive key sorting

Normalize object-key order without reordering arrays.

04

Format or minify

Use one page for readable pretty printing or compact production-style JSON.

Useful answers

Questions about JSON Formatter

Practical details about input, output, privacy, limits, and the best way to use this tool.

01 Does JSON Formatter validate JSON?

Yes. The input is parsed before output is generated. Invalid syntax returns an error instead of formatted text.

02 Can I minify JSON here?

Yes. Select Minify to remove unnecessary formatting whitespace while preserving the JSON data.

03 Does sorting keys change arrays?

No. Recursive key sorting applies to object properties only. Array item order remains unchanged.

04 Does formatting change JSON values?

No. Formatting changes whitespace and, when requested, object-key ordering. Strings, numbers, booleans, nulls and array order are preserved.

05 Which indentation should I use?

Two spaces is common for web projects, four spaces is also widely used, and tabs may be required by some code styles. Choose the format your project expects.

06 Why does my JSON fail to format?

Common causes include trailing commas, single-quoted strings, unquoted keys, invalid escapes, missing commas and incomplete braces or brackets.

07 Is JSON the same as JavaScript object syntax?

No. JSON has stricter syntax. Property names and strings use double quotes, comments are not part of standard JSON, and trailing commas are invalid.

08 What specification defines JSON?

JSON is standardized by RFC 8259 and ECMA-404.

Learn JSON

Read the complete JSON Guide

Learn JSON objects, arrays, value types, validation, formatting, parsing, API workflows, and common syntax errors.

  • Objects, arrays, and values
  • Validation and formatting
  • API and parsing workflows
Read guide Practical explanations and examples

Format and beautify JSON

Pretty printing does not change the meaning of a valid JSON document. It adds consistent indentation and line breaks so nested objects and arrays can be reviewed without manually tracing braces and commas.

Minify JSON

Minification removes formatting whitespace and is useful when you need a compact payload. Whitespace inside quoted string values remains part of the string and is preserved.

Sort JSON keys A–Z

Sorting object keys can make snapshots, examples and manual diffs easier to compare. Because JSON arrays are ordered collections, the formatter never sorts array items automatically.

Common JSON syntax errors

If formatting fails, check for trailing commas, single quotes, unquoted property names, invalid escape sequences, comments, missing commas and mismatched braces or brackets. Use JSON Validator when the goal is specifically to diagnose syntax validity.

Explore and transform JSON

For deeply nested payloads, continue with JSON Viewer or locate values using JSON Path Finder. Convert a hierarchy to reversible paths with JSON Flatten, restore that map with JSON Unflatten, or validate one record per line with JSON Lines Formatter.

JSON standard

The syntax is defined by RFC 8259.