application/json
API Design

Meaning

application/json is the IANA-registered MIME type that identifies a payload as JSON-encoded data. Without it, HTTP receivers have no reliable signal for how to interpret the body, leading to silent misparsing or rejected requests. It is reached for whenever JSON crosses a protocol boundary — request, response, file upload, or stored blob — and the consumer needs to know the encoding contract.

Primary Function

Content type identification

Communicative Purpose

Ensures receivers correctly parse JSON payloads by declaring the standardized media type at protocol boundaries.

Pattern

Content-Type: application/json

Função primária

Content type identification

Propósito comunicativo

Ensures receivers correctly parse JSON payloads by declaring the standardized media type at protocol boundaries.

Situações de gatilho

REST APIs: setting the Content-Type header on HTTP responses carrying JSON bodies HTTP clients: declaring the request body format when POSTing or PUTing JSON File uploads and storage: identifying JSON-formatted blobs in multipart bodies or object stores

Contextos

REST APIs, HTTP clients and servers, web frameworks (Express, Flask, Spring), OpenAPI/Swagger specs, GraphQL transports, cloud object storage, browser fetch API

Padrão

Content-Type: application/json

Colocados típicos

  • Content-Type header
  • Accept header
  • fetch API
  • requests.post(...
  • json=...)
  • res.json()
  • axios.post()
  • express.json()
  • OpenAPI requestBody content map

Substituições comuns

  • application/x-www-form-urlencoded: used for HTML form submissions instead of structured JSON text/json: non-standard legacy variant that some servers reject application/vnd.api+json: vendor-specific variant for JSON:API specification application/hal+json: HAL hypermedia format built on JSON

Erros comuns

Using text/json: non-standard MIME type, many servers and proxies reject it — cause: outdated tutorials, consequence: 415 Unsupported Media Type errors Forgetting the header entirely on POST: cause: assuming the server infers format, consequence: server defaults to form parser and body arrives as raw string Setting application/json but sending form-encoded body: cause: mismatched serialization, consequence: server-side parser throws or returns empty object Adding charset=utf-8 unnecessarily in some clients: cause: copy-paste from older specs, consequence: harmless but signals confusion about JSON's UTF-8 default Confusing application/json with application/javascript: cause: similar naming, consequence: browsers may try to execute the payload as script

Similar / contraste

application/xml: XML data format, requires explicit parser choice text/plain: unstructured text, no parsing contract multipart/form-data: binary file uploads and mixed form fields application/octet-stream: opaque binary blob with no format hint

Interferências

Coming from older web stacks: may use text/json — application/json is the IANA-registered standard and the only universally accepted variant Coming from XML-heavy enterprise APIs: may default to application/xml — JSON APIs require application/json or a vendor-specific JSON subtype Coming from PHP/legacy CMS: may omit Content-Type entirely and rely on server heuristics — modern APIs reject requests without an explicit content type

Família do chunk

  • MIME types
  • Content-Type header
  • Accept header
  • JSON serialization
  • content negotiation

Nuance

When NOT to use: when the payload is not JSON (XML, form-encoded, binary, protobuf) — using application/json with mismatched body causes parse failures. Performance: zero measurable overhead; it is a static header string. Boundary conditions: some servers accept the parameter form application/json; charset=utf-8, but JSON is UTF-8 by RFC 8259 so the parameter is redundant; vendor suffixes like application/vnd.api+json+xml are invalid and must not be combined.

Efeito pragmático

Enables reliable content negotiation across HTTP boundaries so that clients and servers agree on parsing without out-of-band coordination, preventing silent data corruption, 415 errors, and integration failures in production APIs.

Dica de memória

application/json is the universal passport stamped on every JSON payload crossing an HTTP border — without it, the receiving customs office has no idea what language the cargo speaks.

Upgrade path

Content negotiation with vendor-specific JSON subtypes (application/vnd.api+json, application/hal+json, application/ld+json) and structured syntax suffixes (application/problem+json)

Frequência: Very highFormulaicidade: Fully fixedPrioridade de aquisição: Automatic productionPrioridade de output: BothTag de espaçamento: Immediate

Log in to save chunks.