Updated November 24, 2026 | Developer Guides | Applied JSON tutorials

Testing a JSON API involves more than confirming that the response is parseable. A useful test checks status codes, headers, field types, required properties, authorization and boundary cases. This guide combines simple curl commands with a Postman-style testing workflow and explains what a JSON formatter can and cannot prove.

What you will learn: This focused guide covers json api testing with working-style examples, common problems and the next checks needed before relying on the result. Use synthetic inputs when practising online.

Start with a documented test endpoint

Use an API you own or a public testing service that expressly allows the requested actions. Understand the endpoint’s method, expected body, authorization policy and response format. Never run heavy or destructive tests on an unrelated production service.

curl -i -H "Accept: application/json" https://example.com/api/products

The example.com route is illustrative and is not intended to be a functioning public API. Replace it with an authorized test endpoint and inspect both the HTTP headers and returned document.

Check status codes and Content-Type

A successful GET may return 200, while a created resource might return 201. A 204 response normally has no body. Errors may use 400 for invalid input, 401 for missing or invalid authentication, 403 for insufficient authorization and 429 for rate limiting.Inspect Content-Type to determine whether to parse JSON. A proxy or server error can return HTML even when the original request expected JSON. Validate success and failure response formats as part of the API contract.

Send a sample POST request

A typical JSON POST includes a request body serialized as JSON and Content-Type: application/json. In curl, use a carefully quoted body. In Postman, select the appropriate HTTP method and body format before sending. Use synthetic data when practicing.

curl -i -X POST https://example.com/api/items \
  -H "Content-Type: application/json" \
  -d '{"name":"Sample item","quantity":2}'

The server must still validate the request and authorize the action. A syntactically valid payload can contain prohibited values or reference a resource the caller does not own.

Validate response shape with JSON Schema

A contract test should ensure that required fields exist, have correct types and meet defined restrictions. For example, an order response might require an id string and a positive amount. JSON Schema can document these constraints and compatible validators can check results automatically.

{"type":"object","properties":{"id":{"type":"string"},"amount":{"type":"number","minimum":0}},"required":["id","amount"]}

When introducing a new API field, test backward compatibility. Optional fields can be added safely under some contracts, while strict additionalProperties rules may need coordinated updates.

Build a useful test matrix

Test a normal response, an empty list, missing fields, wrong types, malformed JSON, unauthorized access and a temporary server failure. Record expected status codes and representative response bodies. For teams in the USA, UK, Canada, Australia and China, include UTF-8 and regional data cases such as currency codes and multilingual names.Do not treat a passing schema as proof that totals, permissions or account balances are correct. Business invariants require their own assertions.

Frequently asked questions

Does Postman validate JSON? It can parse and support tests, but configure assertions explicitly. Is curl limited to GET? No, it supports many HTTP methods. Is JSON Schema required for APIs? No, but it is useful for formalized contracts. Can I test an API I do not own? Only within its published permissions and terms. Does a formatter replace API tests? No, it helps inspect request and response text. What about 429? Respect rate limits and avoid aggressive retries.

Quick implementation and quality checklist

  • Confirm that the input is valid JSON or an expected source format before transforming it.
  • Check the expected field types, nested structure, empty values and error cases.
  • Use correct UTF-8 handling for multilingual content and protect user or client privacy.
  • Define currency and time-zone rules explicitly for distributed projects serving the USA, UK, Canada, Australia and China.
  • Verify a small representative output against the receiving application’s contract.

These checks support reuse across markets without assuming that every commercial tool or hosted service is available worldwide.

Try related free tools on Perkability Rewards

The links below open existing tools directly, not a new landing page. For context, also see our previously published JSON error fixes and nested JSON arrays articles.

Technical sources and further reading:

Advertising disclosure: This tutorial includes a clearly labeled 160×600 advertising banner and a social-bar script. The scripts are managed by a third-party advertising network; actual delivery varies by browser and platform settings. No claim of search-ranking or traffic results is made.

Leave a Reply

Your email address will not be published. Required fields are marked *