Code Format API - Pretty Print JS, JSON, HTML, CSS, SQL, XML
Applies language-specific formatting rules: JSON uses 2-space indentation via JSON.parse/stringify, HTML and XML indent nested tags, CSS expands rules to one-property-per-line, SQL uppercases keywords and newlines major clauses, and JavaScript follows brace-depth indentation.
Code examples
curl -X POST https://api.botoi.com/v1/code/format \
-H "Content-Type: application/json" \
-d '{"code":"SELECT id, name FROM users WHERE active=true ORDER BY created_at DESC LIMIT 10","language":"sql"}'When to use this API
Format user-pasted snippets in a web app
Users paste unformatted code into a text area; call this endpoint on blur to normalize it. No local Prettier install or browser-bundle weight required.
Pre-commit formatting for generated code
When a codegen step emits JSON or SQL, format it through this endpoint before writing to disk. Keeps generated files readable in pull requests.
Format LLM-generated SQL for review
LLMs often output single-line SQL. Route the response through this endpoint with language:"sql" to get a multi-line form that reviewers can read in Slack or Notion.
Frequently asked questions
Is the JavaScript formatter equivalent to Prettier?
What happens with invalid JSON?
Does SQL formatting work for all dialects?
Is indentation configurable?
Will this fix syntax errors?
Get your API key
Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.