# HTTP API reference

The same engine the viewer runs locally, exposed over HTTP so build scripts, CI jobs and agents can call it. No key, no account, rate limited by IP.

> Read [the privacy page](/docs/privacy) before sending anything sensitive. The browser viewer never transmits your document; the API receives it by definition.

## Endpoints

| Method and path | Purpose |
| --- | --- |
| `POST /api/format` | Beautify or minify a document. |
| `POST /api/validate` | Check syntax and report the first error with line and column. |
| `POST /api/to-typescript` | Generate TypeScript interfaces or type aliases. |
| `POST /api/schema` | Generate a JSON Schema (draft 2020-12 or draft-07). |

## Request

Send `Content-Type: application/json` with a `json` property holding the document **as a string**. Sending it as a string rather than a parsed value is deliberate: it preserves key order, number formatting and whitespace, and it lets `/api/validate` report on documents that are not valid JSON at all.

```bash
curl -sS https://jsonparse.online/api/to-typescript \
  -H 'content-type: application/json' \
  -d '{
        "json": "[{\"id\":1,\"name\":\"Ada\"}]",
        "options": { "rootName": "User", "style": "interface" }
      }'
```

## Response

```json
{
  "ok": true,
  "result": "export interface UserItem {\n  id: number\n  name: string\n}\n\nexport type User = UserItem[]\n",
  "stats": { "bytes": 27, "nodes": 5, "ms": 1 }
}
```

Every endpoint returns `{ "ok": true, ... }` or `{ "ok": false, "error": { "code", "message", ... } }`. A document that will not parse is an `invalid_json` error with `line`, `column`, `offset` and a source `snippet` — except on `/api/validate`, where a malformed document is the expected answer rather than a failure: that endpoint returns HTTP 200 and `{ "ok": true, "result": { "valid": false, "error": { ... } } }`.

## Options

| Endpoint | Options |
| --- | --- |
| `/api/format` | `mode`: `beautify` (default) or `minify`. `indent`: number of spaces, or `"\t"`. |
| `/api/validate` | None. |
| `/api/to-typescript` | `rootName`, `style`, `exported`, `readonly`, `optionalMarker`, `literalUnions`, `indent`, `enumLimit`. |
| `/api/schema` | `title`, `draft`, `closed`, `required`, `inferIntegers`, `detectFormats`, `detectEnums`, `constraints`, `enumLimit`. |

## Limits and errors

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | `invalid_request` | Malformed envelope, missing `json`, or an option out of range. |
| 400 | `invalid_json` | The document does not parse. Carries `line`, `column`, `offset` and `snippet`. |
| 405 | `method_not_allowed` | Only `POST` and `OPTIONS` are accepted. |
| 413 | `payload_too_large` | Body exceeded 4 MB. Use the viewer for anything larger. |
| 415 | `unsupported_media_type` | `Content-Type` was not `application/json`. |
| 429 | `rate_limited` | Too many requests from this address. Honour `Retry-After`. |
| 500 | `internal_error` | Unexpected failure; the response carries a request id. |

CORS is open for `POST` and `OPTIONS`, so the endpoints can be called from a browser. Rate limiting is per instance and per address, and is a courtesy guard rather than a quota: for heavy or continuous use, self-host from [the repository](https://github.com/manishaggarwalm/jsonlens.dev).

## Frequently asked questions

### Is there an API key?

No. The endpoints are open and rate limited by address. There is nothing to sign up for and nothing to revoke.

### Why does the document have to be a string?

Because re-serialising it would destroy exactly the things these endpoints are asked about: key order, number text, whitespace, and in the validator case the syntax error itself.

### What is the largest document the API accepts?

4 MB. The viewer handles documents orders of magnitude larger, because it never has to move them across a network.

---

Source: https://jsonparse.online/docs/api
Last updated: 2026-09-14
JSONParse — Read, search and type huge JSON in your browser
