# GraphQL Formatter & Validator - Minify, Lint, to curl

> Format, minify and validate GraphQL queries and SDL: syntax errors with line and column, unused variables and fragments, curl and fetch snippets, a type graph.

- URL: https://qilingtools.com/en/graphql-format
- Category: Developer Tools (https://qilingtools.com/en/dev)
- Tags: [Developer](https://qilingtools.com/en/tags/dev), [Code Formatting](https://qilingtools.com/en/tags/format), [Network & HTTP](https://qilingtools.com/en/tags/network)
- Last updated: 2026-10-26
- Price: Free, no sign-up
- Privacy: Runs locally in the browser; files are never uploaded

GraphQL copied from logs, network traces or source code is often crammed onto one line or indented every which way. This tool has a lexer and parser written to the GraphQL specification, covering queries, mutations, subscriptions, fragments and inline fragments, variables with defaults, directives and aliases, plus SDL type, interface, enum, union, input, scalar, schema and directive definitions and extend extensions, with descriptions and block strings. Formatting offers 2-space, 4-space or tab indentation and a print width; argument and variable lists that get too long break onto one item per line, and comments stay close to where they were. Minify mode strips comments, commas and extra whitespace for compact request bodies. Syntax errors use graphql-js style messages with the line, column and a caret under the problem. The whole document is analyzed too: every operation and fragment is listed, and you’re warned about variables declared but unused, variables used but not declared (following fragments), unused fragments, unknown fragments, fragment cycles and duplicate names. Pick an operation to build a request containing just it and the fragments it needs, with sample variables filled in from their types, as a POST body JSON, a curl command or fetch() code. Paste SDL and each type is listed with its fields, interfaces, union members, the types it references and the types that reference it, with undefined types flagged. Everything runs in your browser.

## How to use

1. Paste a GraphQL query or SDL, choose Format or Minify, and set indent, print width and whether to keep comments
2. Read the highlighted result; if there’s a syntax error, fix it at the reported line and column
3. Review the outline and checks, build a curl or fetch request for an operation, or browse the SDL type graph

## Features

- Full GraphQL lexer and parser for executable documents and SDL
- Formatting with indent and print width, comments kept
- Minify to the shortest single line
- Syntax errors pinpointed by line and column
- Unused/undeclared variables, unused/unknown fragments and cycles
- Request body JSON, curl and fetch() per operation
- SDL type reference graph
- Syntax highlighting, fully local

## FAQ

### Can formatting change what my query does?

No. Formatting only changes whitespace, line breaks, indentation and commas; escapes in strings are normalized (\u0041 becomes A) but values stay the same. The parser is tested so that formatted output parses to the same syntax tree and formatting it again changes nothing. Minify rewrites block strings as equivalent regular strings.

### Why is a variable reported as unused when a fragment uses it?

The check follows every fragment the operation spreads, including nested ones, so variables used inside them count as used. If you still see the warning, that fragment probably isn’t spread by this operation or its name is spelled differently. The spec requires every declared variable to be used, and servers reject operations that break that rule.

### Does it check fields against my schema?

No. It checks syntax and the document itself — variables, fragments, duplicate names and undefined types — without loading a schema, so it can’t tell whether a field or argument type exists. When you paste SDL, the type graph lists relationships and flags types that are referenced but not defined.

### Can I run the generated curl command as is?

Replace the endpoint with your GraphQL URL and fill in real variable values, and most servers will accept it; add -H 'Authorization: Bearer …' if authentication is needed. The request contains only the selected operation and the fragments it uses, plus operationName. The tool itself never sends anything.

## Related tools

- [JSON Formatter](https://qilingtools.com/en/json): Free online JSON formatter: beautify or minify, validate with the exact line and column of any error, browse a collapsible tree, sort keys and escape strings.
- [Base64 Encode/Decode](https://qilingtools.com/en/base64): Free online Base64 encoder and decoder: UTF-8 safe, optional URL-safe variant, convert text to Base64 and back in real time. Processed locally, never uploaded.
- [URL Encode/Decode](https://qilingtools.com/en/url-encode): Free online URL encoder and decoder with encodeURIComponent and encodeURI modes. Escapes Chinese, spaces and special characters. Real-time and local, no upload.
- [JWT Decoder](https://qilingtools.com/en/jwt): Free online JWT decoder: decode the header and payload of a JSON Web Token, show expiry and issued-at times, all locally without uploading the token.
- [Timestamp Converter](https://qilingtools.com/en/timestamp): Free online Unix timestamp converter: convert timestamps and dates, auto-detect seconds or milliseconds, and show local, UTC, ISO 8601 and relative time.
- [Hash / Checksum](https://qilingtools.com/en/hash): Free online hash calculator: SHA-1, SHA-256, SHA-384 and SHA-512 of text or any file through the browser crypto API. Files never leave your device.
- [UUID Generator](https://qilingtools.com/en/uuid): Free online UUID generator: create RFC 4122 UUID v4 in bulk with a cryptographic RNG. Options for uppercase, no hyphens and braces, with one-click copy.
- [Base Converter](https://qilingtools.com/en/base-convert): Free online number base converter: convert between binary, octal, decimal, hexadecimal and any base 2–36. Uses BigInt for huge integers, computed locally.
