Contents

API responses often arrive as compact, single-line JSON that hides the structure developers need to verify before writing application code. FormatBits is an in-browser developer workbench that formats, validates, and minifies JSON while processing data locally, so pasted API responses stay inside the browser. Only the JSON Formatter, URL Codec, and Timestamp Converter modules are enabled. This guide explains how to pretty-print nested JSON for debugging, what JSON syntax rules apply, how Google’s JSON style guidance treats property names, and how to work through a repeatable response-checking workflow.
Pretty-Printing Nested JSON for API Debugging
Pretty-printing turns a dense JSON string into an indented, readable layout that makes object boundaries, arrays, and deeply nested keys visible. When a response arrives compactly, fields can be easy to overlook. By copying the response body exactly as received and running it through the JSON Formatter, developers can see each nesting level clearly before changing application code.
Indentation is especially useful when the expected field location does not match the actual payload. For example, code might read data.user, but formatting could reveal that the value is nested under data.result.user. Without pretty-printing, that mismatch might be mistaken for a missing field or a failed request.
Pretty-printed output also shows whether a property contains an object, an array, or a scalar value. Arrays appear with bracket notation and can reveal repeated items that need looping logic in the frontend. Nested objects appear with their own indentation levels, making it easier to trace paths such as response.items[0].details.price.
Formatting does not change the data semantics; it only adds whitespace for readability. Production responses may omit unnecessary whitespace to reduce size, while staging and development environments can pretty-print responses to assist debugging. All keys in FormatBits-supported JSON should remain camelCased according to project style guidance.
Practical workflow
- Copy the raw response body exactly as received from the browser network panel or API client.
- Paste it into the JSON Formatter module.
- Validate before editing any application code that depends on the shape.
- Pretty-print and inspect object boundaries, arrays, and nested keys.
- Note any path mismatches, such as
data.result.userversusdata.user,
and update the accessor code accordingly.
Developers working with staging endpoints can compare pretty-printed responses against local fixtures to confirm that new fields have been added in the expected locations.
JSON Syntax Rules and Property Naming
Before the JSON Formatter can process a raw API response, the payload must satisfy core JSON validity requirements. Valid JSON needs double-quoted property names and strings. Trailing commas and comments are not allowed in JSON objects. If a response contains single-quoted keys, unquoted strings, comments, or trailing commas, the formatter will not treat it as valid JSON until those issues are corrected.
Numeric precision is preserved during formatting, which matters for API responses that include timestamps, monetary amounts, or identifiers with many digits. Duplicate keys are flagged rather than silently overwritten, helping developers detect when a server sends the same property more than once.
Google’s JSON style guidance provides naming recommendations that apply when inspecting or designing API payloads. Property names should be lower camel-cased ASCII strings starting with a letter, underscore, or dollar sign. Subsequent characters can be letters, digits, underscores, or dollar signs. Array types should use plural property names, while all other property names should be singular. For example, items is appropriate for an array, whereas item fits a single object value.
Reserved top-level property names include apiVersion, context, id, method, params, data, and error. The error object reserves additional names such as code, message, errors, domain, reason, location, and extendedHelp. Paging reserved names include currentItemCount, itemsPerPage, startIndex, totalItems, pageIndex, and totalPages. Link reserved names under the data object include self, selfLink, edit, editLink, next, nextLink, previous, and previousLink.
These conventions do not guarantee that every API follows them, but they provide a useful baseline for comparing an observed payload against an expected contract. If a response uses different casing or reserved names unexpectedly, developers should check the API documentation rather than assume the server is wrong.
Tool Boundaries and Privacy Model
FormatBits processes data locally in the browser with no uploads. Pasted API responses do not leave the client during formatting, validation, minification, URL encoding or decoding, or timestamp conversion. This local-only behavior supports privacy-conscious debugging when working with tokens, personal data, or internal API payloads.
Only three modules are enabled: JSON Formatter, URL Codec, and Timestamp Converter. Base64 encoding and decoding are mentioned in the broader product brief but are not part of the enabled toolset in this version.
Each FormatBits check supports UTF-8 payloads up to 256 KiB. Input data lives in the browser during formatting rather than being sent to a remote server. Developers should still avoid pasting long-lived secrets into any browser tool unless they understand the local storage and session behavior of their environment.
URL encoding scope options
The URL Codec offers Encode or Decode operations. Scope can be set to One value or A whole URL. For one value, reserved characters are encoded, including /, ?, &, and =. A whole URL keeps separators such as ? and & intact. Use one-value encoding when encoding a single query parameter value, and whole-URL encoding when the structure of the URL itself must remain readable.
Timestamp conversion
The Timestamp Converter supports conversion between Unix timestamps and ISO 8601 dates. Input unit choices are Seconds or Milliseconds. Negative timestamps are supported. Developers should verify which unit an API returns before converting, because interpreting milliseconds as seconds produces dates roughly one thousand times too far in the future or past.
Module boundaries at a glance
| Module | Main purpose | Input limit | Processing location |
|---|---|---|---|
| JSON Formatter | Format, validate, and minify JSON | Up to 256 KiB UTF-8 per check | Local browser |
| URL Codec | Encode or decode one value or a whole URL | Up to 256 KiB UTF-8 per check | Local browser |
| Timestamp Converter | Convert Unix timestamps and ISO 8601 dates | Up to 256 KiB UTF-8 per check | Local browser |
Debugging Checklist for API Responses
A repeatable checklist helps teams avoid assumptions about response shape and catch contract mismatches early. Use this sequence when inspecting an API response in FormatBits.
- Confirm the HTTP status code and response content type. A successful status does not guarantee valid JSON, and an error response may return HTML or plain text instead.
- Copy the response body exactly as received. Do not retype or reformat manually before validation.
- Validate the raw JSON in the JSON Formatter. Check for double-quoted names and strings, absence of trailing commas and comments, and any flagged duplicate keys.
- Pretty-print the validated JSON. Inspect object boundaries, arrays, and deeply nested keys to verify the actual structure.
- Compare the observed shape against the API contract. Pay special attention to nested paths such as
data.result.userversusdata.user. - Decode any nested encoded values using the URL Codec if the payload contains encoded query strings or URL fragments.
- Convert any Unix timestamps to ISO 8601 dates using the Timestamp Converter, confirming whether the input unit is seconds or milliseconds.
- Save a regression fixture from the formatted output. Fixtures make it easier to detect future changes to field names, nesting, or paging properties.
Reader questions
- How does pretty-printing expose a mismatch such as reading
data.userwhen the value is underdata.result.user? It makes indentation levels visible, so the extraresultobject can be seen before the code fails at runtime. - Which syntax rules must a response satisfy before formatting? Double-quoted property names and strings, no trailing commas, no comments, and valid object or array structure.
- Which reserved top-level names commonly appear in API responses? Examples include
apiVersion,data, anderror, with additional reserved names inside error, paging, and link objects. - What input limit applies per check? Up to 256 KiB of UTF-8 payload, processed locally in the browser.
Teams can adapt this checklist by adding status-specific branches, expected schema checks, or fixture storage locations suited to their repository and deployment pipeline.