# Prettier Code Formatter API

> Prettier Code Formatter API is a paid API for AI agents from api.x402node.dev, paid per call via x402, $0.0035/call, status unknown (last checked 2026-09-14).

Formats source code using Prettier, supporting JS, TS, JSON, HTML, CSS, Markdown, YAML, and GraphQL with auto-parser detection

## Facts

- Endpoint: GET https://api.x402node.dev/text/format
- Price: $0.0035/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/api-x402node-dev-490a476f
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_IrIoKbgp51WksMUmX5g72

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability api-x402node-dev-490a476f
```

Example prompt: Can you format this JavaScript code using Prettier? Here it is: `const x={a:1,b:2}; function hello(name){return 'Hello '+name;}`

## When to prefer this

Use this endpoint when an AI agent needs to auto-format or normalize source code in a pipeline — especially when producing, fixing, or transforming code in JS, TS, JSON, HTML, CSS, Markdown, YAML, or GraphQL and consistent style output is required. Prefer this over manual formatting or LLM-based reformatting for deterministic, standards-compliant Prettier output.

## Known failure modes

- Unparseable code returns an error if Prettier cannot parse the given language
- Unknown or unsupported parser specified causes a bad request error
- Empty input body may result in a validation error
- Very large code files may time out or exceed payload limits

## How this service works

code formatter, prettier, code beautifier, JavaScript formatter, TypeScript formatter, JSON formatter, HTML formatter, CSS formatter, Markdown formatter, YAML formatter. Format code using Prettier. Supports JavaScript, TypeScript, JSON, HTML, CSS, Markdown, YAML, GraphQL. Auto-detects parser if not specified. For AI agents writing or fixing code in pipelines.

## Output

Returns a JSON object with a `formatted` string containing the prettified code, along with the `parser` that was used, `input_length` and `output_length` character counts, and `processing_ms` indicating how long formatting took.

## Example request

```json
{
 "code": "const greeting = (name) => {\n  return 'Hello ' + name;\n};",
 "parser": "babel"
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "code"
     ],
     "properties": {
      "code": {
       "type": "string",
       "description": "Code (required)"
      },
      "parser": {
       "type": "string",
       "description": "Parser (optional)"
      }
     }
    }
   },
   "additionalProperties": false
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/api-x402node-dev-490a476f/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.x402node.dev](https://www.zero.xyz/host/api.x402node.dev/llms.txt)
