GraphQL Formatter & Beautifier - Free Online
What is a GraphQL formatter?
A GraphQL formatter restructures queries, mutations, and schemas with consistent indentation and spacing. It makes nested fields, fragments, and arguments easy to scan while catching common syntax issues. Use it to review API calls, document examples, or clean server schemas without opening an IDE.
How to use the GraphQL formatter
- Paste GraphQL: Drop in a query, mutation, fragment, or schema SDL.
- Choose indentation: Select 2 or 4 spaces to match your style.
- Get results: See formatted GraphQL instantly. Copy it or download as a .graphql file.
Why use this formatter?
- Faster debugging: Spot missing braces, commas, or unmatched brackets quickly.
- Clear docs: Share readable examples in API guides and pull requests.
- Local privacy: All parsing happens in your browser, so API details stay private.
Use case 1: Client queries
Format complex queries with nested selections before shipping them in your frontend.
Use case 2: Schema reviews
Beautify SDL for schema diffs to confirm types, directives, and deprecations.
Use case 3: Learning and demos
Prepare tidy examples for workshops or onboarding decks.
Examples
Basic example
Input: query{user{id name friends{email}}}
Output:
query {
user {
id
name
friends {
email
}
}
}
Advanced example
Input: Minified schema with interfaces and unions
Output: Indented types, interfaces, and union definitions with fields on separate lines.
Common errors
Missing braces or parentheses
If parsing fails, check for unmatched { } or ( ). The formatter points to the first issue.
Invalid commas
GraphQL does not allow trailing commas in many positions. Remove them and retry.
Tips and proven approaches
- Keep 2-space indent for compact queries; 4-space for teaching material.
- Pair with the JSON formatter when inspecting GraphQL responses.
- For variables, format the JSON payload separately with the JSON formatter.
Related tools
- Format schemas’ supporting files with the TypeScript formatter.
- Clean REST payloads using the JSON formatter.
Privacy and security
Formatting runs locally in your browser. No GraphQL queries or schemas are uploaded or stored.