API Payload Formatter
Fast, accurate, and free online API Payload Formatter tool that runs directly in your browser.
-
1Enter data
Enter content, paste text or load a file from disk. -
2Click the button
The tool will immediately process your data in the browser. -
3Get the result
Copy the finished text or save the file to your device.
return "Result ready in 0.1s";
}
{
"event": "user.created",
"meta": {
"ip": "203.0.113.10",
"source": "web"
},
"user": {
"email": "[email protected]",
"id": 12345,
"profile": {
"firstName": "Alice",
"lastName": "Nowak",
"locale": "pl-PL"
}
}
}
Rate this tool:
Related tools
Other tools you may find usefulAPI payload formatter – JSON, XML, YAML with syntax coloring
Working with the API requires constant formatting and validation of payloads: unstructured JSON from the response, compressed XML from the webservice, nested YAML from the configuration. The tool formats with syntax coloring, detects errors and minifies for production.
Supported formats and features
JSON: 2/4 space or tab indented formatting, key sorting (optional), minification, RFC 7159 validation. XML: pretty-print indented, well-formedness validation, namespace-aware. YAML: dimpled formatting, conversion to/from JSON. GraphQL: formatting queries and mutations.
Formatting vs minification
Pretty-print (readable): indents, new lines, spaces after colons. Size ~2-4× larger than minified. Minification: removing unnecessary whitespace. JSON: {"key":"val"} instead of { "key": "val" }. Usage: pretty-print for debugging and documentation; minified for production (less transfer).
Error detection and validation
JSON: "unexpected token" (no quotes, trailing commas, comments). XML: "mismatched tag" (unclosed element), "invalid character" (& no entity). YAML: indentation errors, tab chars, no space after colon. The tool indicates the line and column number of the error.
Diff and payload comparison
Diff mode: compare two JSON/XML side-by-side (coloring added/removed/changed keys). Useful: comparison of API v1 and v2 responses, verification that the deployment has not changed the structure. JSON Patch (RFC 6902): JSON changelog.
Frequently asked questions
How to generate valid JSON payload?
Keys in double quotes (not single quotes). No trailing comma after the last element. null/true/false (not NULL/True). Strings with escape: \" (quote), \n (newline), \\ (backslash). Encoding: UTF-8. There are no comments in JSON (use JSONC or remove before sending).
What is application/json vs text/plain?
Content-Type: application/json tells the API that the body is JSON. Without this header: the server may reject or misparse. For sending: -H "Content-Type: application/json" in cURL. Accept: application/json: tells the server that the client expects JSON in the response.
How to debug invalid payload XML?
Check 1) XML declaration (xml version="1.0" encoding="UTF-8"?). 2) Root element (exactly one). 3) Closed tags (
What is GraphQL payload and how to format it?
GraphQL query: { user(id: 1) { name, email, posts { title } } }. Mutation: mutation { createUser(name: "John") { id } }. Variables: {"id": 1}. Endpoint: POST /graphql with body: {"query":"...","variables":{...}}. The tool formats with syntax highlighting and basic validation.
How to use the tool with Postman/Insomnia?
Copy the body request or response from Postman. Paste into tool. Click "Format". Copy the formatted result back to Postman. Alternative: Postman has a built-in "Bautify" (Ctrl+B) for JSON, but not for XML. The tool supports all formats.
Related tools: JSON validator, JSON to CSV converter and cURL to Fetch API converter.