Format
GraphQL Formatter, Minifier & Validator Online
Format, minify and validate GraphQL queries and schemas, with optional schema-aware checks.
Runs entirely in your browser — nothing you paste is uploaded or stored.
What is graphql formatter & validator?
GraphQL queries are usually written on one line in application code, copied out of a network panel, or generated by a client library, which makes them hard to read and review. This tool does three jobs on GraphQL text. Format pretty-prints a query, mutation, fragment or schema with consistent two-space indentation. Minify strips whitespace, commas and comments to the smallest equivalent document, which is useful for persisted queries and request bodies. Validate checks the syntax and the rules that do not need a schema, and when you paste a schema (SDL) alongside a query it also checks that every field, argument and type exists. It runs the reference GraphQL parser, so what it accepts and rejects matches what a real server does.
When to use it
- Making a one-line query from a network request or a client library's debug log readable before you edit it.
- Minifying a query to embed in a request body, a persisted-query manifest or a test fixture.
- Checking that a new query is valid against the schema before committing it, without running a server.
- Catching a duplicate operation name, an unused fragment or an undefined variable in a large document.
- Validating a hand-written schema for unknown types and other structural mistakes.
How to use this tool
- Paste a query, mutation, fragment or schema, or click "Load example" to see a working sample.
- Pick Format to pretty-print, Minify to compress, or Validate to check it.
- In Validate mode, optionally paste your schema in the second box so field and type names are checked too.
- Copy the result, download it as a .graphql file, or copy a link that restores this exact input.
Example
A one-line query, formatted.
Input
query GetUser($id: ID!) { user(id: $id) { id name email posts(first: 3) { title publishedAt } } }Output
query GetUser($id: ID!) {
user(id: $id) {
id
name
email
posts(first: 3) {
title
publishedAt
}
}
}Each selection set gets its own indented block, so the shape of the response is visible at a glance.
Formatting with a real parser
A formatter built on regular expressions breaks on a { inside a string or a # that is not
a comment. This tool uses graphql-js, the reference
implementation that most GraphQL servers are built on, to parse the input first and print it
from the syntax tree. That is also why invalid input is reported with a line and column: the
same parser that formats your query is the one that rejects it.
Frequently asked questions
Why were my comments removed?
The GraphQL reference printer works from the parsed syntax tree, and comments are not part of it, so formatting and minifying both drop them. The tool tells you when this happened. If your comments matter, format a copy and add them back by hand, or use an editor plugin that preserves them.
Does Validate check my query against my API?
Only against a schema you paste in. Without a schema, it checks syntax plus the rules that never need one, such as duplicate operation names, unknown or unused fragments and undefined or unused variables. It cannot know whether a field exists until it sees the schema. It never contacts your server.
What is the difference between a document and a schema here?
A document is what clients send, such as queries, mutations, subscriptions and fragments. A schema is the server's type definitions, written in SDL with `type`, `input`, `enum` and similar keywords. The tool detects which one you pasted and applies the matching checks.
Why does a schema without a Query type count as valid?
Pasting a piece of a schema is common, and reporting a missing root type would be noise. The tool treats it as valid and adds a note. A complete schema served by a GraphQL server does need a Query type.
Will minifying change what my query does?
No. Only characters the GraphQL grammar ignores are removed, namely whitespace, commas and comments. Names, arguments, string contents and block strings are untouched, so the minified document is equivalent to the original.
Is my query or schema sent anywhere?
No. Parsing and validation run in your browser tab, and nothing you paste is uploaded. The parser library loads only when you first use this tool.
Is there a size limit?
Yes, 500,000 characters. Parsing is synchronous and runs in your browser tab, so a larger input could freeze the page. Documents of that size are almost always generated.
Find these tools useful? A coffee helps keep them free and ad-light.
Buy me a coffee