{"uid":"cap_SAFg-BkYLuSxbDWFS479q","slug":"json-format-pretty-print-or-minify-json-c13bb102","name":"JSON Format – Pretty-Print or Minify JSON","description":"Pretty-print or minify JSON, optionally sorting keys, and report the size before and after.","url":"https://json-data-tools.x402tookit.com/json-format?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":["json"],"properties":{"json":{"type":"string","description":"The JSON text"},"sort":{"type":"string","description":"true to sort keys"},"indent":{"type":"integer","description":"Spaces 0 to 8; 0 minifies. Default 2"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"asOf":{"type":["null","string"]},"source":{"type":["null","string"]},"reasons":{"type":["array","null"]},"summary":{"type":["null","string"]},"verdict":{"type":["null","string"]},"degraded":{"type":["boolean","null"]},"formatted":{"type":["null","string"]},"disclaimer":{"type":["null","string"]},"notChecked":{"type":["array","null"],"items":{"type":"string"}},"charactersAfter":{"type":["null","number"]},"charactersBefore":{"type":["null","number"]}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_XOzD0JOWqL1o1SZwsiBv5","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Pretty-prints or minifies a JSON string with optional key sorting, returning the reformatted text plus before/after character counts.","exampleAgentPrompt":"Can you pretty-print this JSON for me with 4-space indentation and sort the keys alphabetically: {\"z\":1,\"a\":2,\"m\":{\"b\":3,\"a\":4}}? Also tell me how many characters it is before and after.","exampleUseCases":[{"title":"Beautify API response for debugging","prompt":"I got this raw JSON back from an API call and it's all on one line — can you format it with 2-space indentation so I can read it? Here it is: {\"user\":{\"id\":123,\"name\":\"Alice\",\"roles\":[\"admin\",\"viewer\"]}}"},{"title":"Minify JSON for production payload","prompt":"Can you minify this JSON down to zero indentation so I can embed it compactly in my config? I also want to know how many characters it shrinks by: {\"host\": \"localhost\", \"port\": 5432, \"db\": \"myapp\"}"},{"title":"Sort JSON keys for canonical representation","prompt":"Take this JSON object and reformat it with sorted keys and 2-space indentation — I need a deterministic, canonical form for checksumming: {\"z\":true,\"a\":\"hello\",\"m\":42}"}],"resultDescription":"Returns the reformatted JSON string (pretty-printed or minified, with keys optionally sorted), plus the character count of the input before formatting and the output after formatting, allowing you to measure compaction or expansion.","failureModes":["Invalid JSON input returns an error response rather than formatted output","Extremely large JSON strings may time out or hit size limits","Malformed query parameters (e.g. non-integer indent) may cause a 400 error","Network or payment (x402) failures result in no response"],"whenToPreferThis":"Choose this endpoint when you need to reformat, compress, or canonicalize a JSON string and also want to know the before/after size impact. It combines pretty-printing, minification, and key sorting in a single call, making it ideal for pipelines that need a consistent JSON representation or want to measure payload size reduction.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-30T00:30:42.469Z","isFirstParty":false,"canonicalSlug":"json-format-pretty-print-or-minify-json-c13bb102"}