application/json MIME Type — Content-Type, HTTP Headers & Examples
JavaScript Object Notation. The standard data interchange format for web APIs, configuration files, and structured data storage. Human-readable, language-independent, and natively parsed by JavaScript.
Used For
- REST API requests and responses
- Configuration files (package.json, tsconfig.json)
- Webhook payloads
- LocalStorage data
HTTP Header Example
POST /api/users HTTP/1.1
Content-Type: application/json
Accept: application/json
{"name": "Alice", "email": "alice@example.com"}Code Examples
// Fetch API (browser / Node.js 18+)
const response = await fetch('/api/users', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: 'Alice', email: 'alice@example.com' }),
})
const data = await response.json()
// Express.js — serve JSON
app.get('/users', (req, res) => {
res.json({ users: [] }) // sets Content-Type: application/json automatically
})
// Next.js App Router
export async function GET() {
return Response.json({ users: [] }) // application/json by default
}Related MIME Types
Frequently Asked Questions
What is the application/json MIME type?
JavaScript Object Notation. The standard data interchange format for web APIs, configuration files, and structured data storage. Human-readable, language-independent, and natively parsed by JavaScript.
When should I set Content-Type: application/json?
Set Content-Type: application/json on HTTP responses that contain JSON data. REST API requests and responses.
What file extensions use application/json?
Files with application/json content typically use these extensions: .json.
What happens if I serve this with the wrong Content-Type?
Browsers use the Content-Type header to decide how to handle the response. Serving application/json content with an incorrect MIME type can cause browsers to display it incorrectly, refuse to execute it (scripts), or prompt an unintended download. Modern browsers respect X-Content-Type-Options: nosniff and will not attempt to auto-detect the type.
