
Code Beautifier API
Development
Format and beautify your code, JSON, XML, and other formats with customizable options.
Authentication
All API requests require a valid API key passed in the Authorization header as a Bearer token.
Rate Limit
100 requests per minute
Endpoints
1 endpoint available
Overview
The Code Beautifier API formats and beautifies code using Prettier with extensive customization options.
Supported Languages
- JSON
- HTML
- XML (uses HTML parser)
- JavaScript
- TypeScript
- CSS
- Markdown
- YAML
- Auto-detect (based on content)
Use Cases
- Format code before committing to repositories
- Standardize code style across projects
- Beautify minified or compressed code
- Integrate code formatting into CI/CD pipelines
Endpoints
POST
/v1/tools/code-beautifierFormat and beautify code with customizable options
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| code | string | Required | The code to format |
| language | string | Optional | Language: "auto", "json", "html", "xml", "javascript", "typescript", "css", "markdown", "yaml" (default: "auto") |
| options | object | Optional | Formatting options |
| options.printWidth | number | Optional | Line width (default: 80) |
| options.tabWidth | number | Optional | Spaces per indentation level (default: 2) |
| options.useTabs | boolean | Optional | Use tabs instead of spaces (default: false) |
| options.semi | boolean | Optional | Add semicolons (default: true) |
| options.singleQuote | boolean | Optional | Use single quotes (default: false) |
| options.trailingComma | string | Optional | Trailing commas: "none", "es5", "all" (default: "es5") |
| options.bracketSpacing | boolean | Optional | Spaces in object literals (default: true) |
| options.arrowParens | string | Optional | Arrow function parens: "avoid", "always" (default: "avoid") |
| options.proseWrap | string | Optional | Prose wrapping: "always", "never", "preserve" (default: "preserve") |
| options.htmlWhitespaceSensitivity | string | Optional | HTML whitespace: "css", "strict", "ignore" (default: "css") |
Response Example
{
"success": true,
"data": {
"formattedCode": "{\n \"name\": \"example\",\n \"version\": \"1.0.0\"\n}\n",
"language": "json",
"inputLength": 35,
"outputLength": 42
}
}Error Codes
400
Bad Request - Missing code or invalid syntax401
Unauthorized - Invalid or missing API key429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorCode Examples
curl -X POST https://api.opentools.ca/v1/tools/code-beautifier \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "{"name":"example","version":"1.0.0"}",
"language": "json",
"options": {
"tabWidth": 2,
"printWidth": 80
}
}'