API Response Formatter

Paste raw JSON, XML, or HTML β€” auto-detect format, pretty-print with syntax highlighting.

Raw Input

What is API Response Formatter?

API Response Formatter formats and highlights raw API responses (JSON, XML, YAML, and plain text) with syntax highlighting, collapsible tree view, line numbers, and copy buttons. Paste a raw API response to get an indented, readable version with clickable paths that let you extract specific values. It also validates the response for syntax errors and shows the character count and nesting depth.

Raw API responses are often minified (no whitespace) to minimize payload size. For debugging, you need the response formatted for human reading. This formatter handles common API response formats and transforms minified responses into indented, syntax-highlighted representations. It also detects and highlights syntax errors with line/column numbers to help you spot malformed responses.

JSON (JavaScript Object Notation) is the dominant API response format. REST APIs almost universally return JSON. XML was the standard for SOAP APIs and is still used by some enterprise systems (Salesforce, SAP). YAML is used by Kubernetes, CI/CD configurations, and some API specifications (OpenAPI). GraphQL responses are always JSON. Protocol Buffers (protobuf) are binary β€” use the appropriate serializer library rather than a text formatter.

How to Use

  1. Paste your raw API response into the input field.
  2. Click 'Format' to pretty-print the response with indentation and syntax highlighting.
  3. Click any key in the tree view to copy its full JSON path (e.g., data.users[0].email).
  4. Use the 'Validate' button to check for syntax errors β€” errors are highlighted with line numbers.
  5. Toggle 'Minify' to compress the response back to a single line for embedding in code.

Examples

Minified JSON API response

Result: {'id':1,'name':'Alice','email':'alice@example.com'} β†’ formatted with 4-space indentation

Extract specific value

Result: Click on 'email' key β†’ copies '$.data.users[0].email' path for use in jq queries

XML SOAP response

Result: Formats and highlights XML elements, attributes, and namespaces with collapsible tree

Frequently Asked Questions

What is the difference between REST and SOAP API responses?

REST APIs typically return JSON (sometimes XML) and use HTTP status codes to indicate success/failure. The response body contains just the data. SOAP APIs always return XML wrapped in a SOAP envelope with a header and body. SOAP responses include the operation name and are more verbose. REST is preferred for new APIs; SOAP is found in enterprise/legacy systems.

How do I format JSON in the terminal?

Use jq: echo '$JSON' | jq . β€” this pretty-prints with colors. For Python: echo '$JSON' | python3 -m json.tool. For Node.js: node -e "console.log(JSON.stringify(JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')),null,2))". jq is the most powerful option β€” it can also query and transform JSON.

What does HTTP 200 vs 201 vs 204 mean in API responses?

200 OK: Successful GET or POST. 201 Created: Successful POST that created a resource (includes the created resource or its location in the Location header). 204 No Content: Successful action with no response body (common for DELETE or PUT). 400 Bad Request: Invalid request syntax. 401 Unauthorized: Missing or invalid authentication. 403 Forbidden: Authenticated but not authorized. 404 Not Found: Resource doesn't exist.

What is JSON Schema and how do I validate an API response against it?

JSON Schema is a vocabulary to describe and validate JSON structure. A schema defines required fields, data types, string patterns, number ranges, and array constraints. Tools: ajv (Node.js), jsonschema (Python), JSON Schema Validator websites. OpenAPI specifications embed JSON Schema to document and validate both request bodies and response formats. This catches structural mismatches between API docs and actual responses.

Why do API responses sometimes include null vs missing fields?

APIs differ in how they represent absent values. An explicit null (key present, value null) means 'this field exists but has no value.' A missing key means 'this field is not relevant or not applicable.' Some APIs use nulls for consistency (every field always appears in the response). Others omit null fields to reduce payload size. When parsing, treat both cases β€” check for key existence and then for null value.

Related Tools