Endpoint
POST https://json-to-ts-app.netlify.app/api/convert
Send Content-Type: application/json. Body:
| Field | Type | Required | Notes |
|---|---|---|---|
json | string | yes | The JSON payload to convert, as a string. The endpoint JSON.parses it. |
mode | string | no (default "ts") | One of "ts" | "zod" | "valibot". |
root | string | no (default "Root") | Name of the root interface / type / schema in the generated code. |
type | boolean | no (default false) | ts mode only — true emits a type alias instead of an interface. |
Responses: 200 {"output": "<generated code>"} on success, 400 {"error": "<reason>"} on malformed input, 405 if the method is not POST. CORS is wide-open (Access-Control-Allow-Origin: *) so browser callers work too.
curl examples
Three working examples — one per output mode — using a real Stripe checkout.session.completed event as the payload. Copy any of them into a shell.
1. JSON → TypeScript interface
curl -X POST https://json-to-ts-app.netlify.app/api/convert \
-H 'Content-Type: application/json' \
-d '{"json":"{\"id\":\"evt_1NQz5KJZ7p9KqYxRxMm8LgxF\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3D4e5F6g7H8i9J0kLmNoP\",\"amount_total\":2000,\"currency\":\"usd\",\"customer_email\":\"alice@example.com\",\"payment_status\":\"paid\"}},\"livemode\":false}","mode":"ts","root":"Stripe"}'
2. JSON → Zod schema
curl -X POST https://json-to-ts-app.netlify.app/api/convert \
-H 'Content-Type: application/json' \
-d '{"json":"{\"id\":\"evt_1NQz5KJZ7p9KqYxRxMm8LgxF\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3D4e5F6g7H8i9J0kLmNoP\",\"amount_total\":2000,\"currency\":\"usd\",\"customer_email\":\"alice@example.com\",\"payment_status\":\"paid\"}},\"livemode\":false}","mode":"zod","root":"Stripe"}'
3. JSON → Valibot schema
curl -X POST https://json-to-ts-app.netlify.app/api/convert \
-H 'Content-Type: application/json' \
-d '{"json":"{\"id\":\"evt_1NQz5KJZ7p9KqYxRxMm8LgxF\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3D4e5F6g7H8i9J0kLmNoP\",\"amount_total\":2000,\"currency\":\"usd\",\"customer_email\":\"alice@example.com\",\"payment_status\":\"paid\"}},\"livemode\":false}","mode":"valibot","root":"Stripe"}'
About this endpoint
The HTTP API at /api/convert is the same conversion algorithm that powers the hosted UI at the homepage and the @solvohq/json-to-ts npm CLI — three artifacts, one algorithm. Use it from a shell script (curl), a CI step (GitHub Action, GitLab CI), a Postman collection, or any language with an HTTP client. POST a JSON body, get back a JSON body with the generated code as a string. No SDK to install, no API key to manage, no rate limit until abuse forces one.
Why an HTTP endpoint when the hosted UI already exists: scripts and pipelines can't paste into a textarea. If you're regenerating types for a fixture directory, smoke-testing a webhook payload from a CI job, building an internal tool that wraps this conversion, or writing a Postman/Insomnia plugin — the API is the right shape. The hosted UI is for the one-off paste; the npm CLI is for `npx json-to-ts < input.json`; this API is for HTTP-native callers (other languages, other tools, other services).
Endpoint contract: POST application/json to https://json-to-ts-app.netlify.app/api/convert with body {"json": "<stringified-json>", "mode": "ts" | "zod" | "valibot", "root": "Root" (optional), "type": false (optional, ts only)}. Returns 200 with {"output": "<generated code>"} on success, 400 with {"error": "<reason>"} on bad input, 405 if the method isn't POST. CORS is wide-open so browser calls work too. The function is hosted on Netlify Functions free tier — heavy traffic is metered against the project, not against you.