GraphQL Formatter
Format and beautify GraphQL code instantly in your browser with Prettier's GraphQL parser (MIT-licensed). No uploads, no sign-up, works offline.
Why use a GraphQL formatter for queries and schemas?
GraphQL has become the API layer of choice for modern frontend applications, powering everything from e-commerce storefronts to enterprise dashboards. As teams grow and GraphQL documents multiply, inconsistent formatting quickly becomes a hidden maintenance cost. Developers spend mental energy decoding deeply nested, single-line queries instead of focusing on logic. A dedicated GraphQL formatter eliminates that friction by reprinting every document to a canonical style in milliseconds.
- Consistent indentation: Every selection set is indented by two spaces, making deeply nested queries scannable at a glance without manually counting braces.
- Operation name visibility: Formatted output makes unnamed operations immediately obvious, encouraging the discipline of naming every query, mutation, and subscription for better server-side tracing.
- Fragment alignment: Fragment definitions are formatted identically to inline selections, so shared fragments remain readable even when they grow to dozens of fields.
- Variable clarity: Query variables and their types are printed one-per-line, preventing the wall-of-text effect that appears when multiple variables are crammed onto a single line.
Prettier GraphQL parser architecture
Under the hood, ToolJiffy's GraphQL formatter uses Prettier's GraphQL plugin, shipped as part of the core Prettier package under the MIT licence. Prettier works by first parsing your GraphQL text into an abstract syntax tree (AST) using the graphql-js parser, then running its own "doc IR" algorithm to decide line breaks and indentation, and finally printing the IR back to a string. This two-pass approach means the output is always semantically identical to the input — no field is added, removed, or reordered. Because Prettier is opinionated by design, there are no formatting options to configure; every developer on your team gets the same output, eliminating style debates in code review.
Client-side security for private GraphQL schemas
Many GraphQL schemas contain sensitive business logic: custom directives that encode authorization rules, type names that reveal internal microservice boundaries, or field descriptions that document proprietary data models. ToolJiffy processes everything locally in your browser. Your schema definition never touches our servers, is never logged, and is never stored — it exists only in your browser's JavaScript runtime for the fraction of a second it takes to format.
This client-side architecture is especially important for teams that work under compliance frameworks such as SOC 2, HIPAA, or GDPR, where transmitting schema details to third-party services may require legal review. With ToolJiffy, there is nothing to review — no data leaves the browser.
Step-by-step guide to formatting a GraphQL document
- Paste your GraphQL text. Copy any query, mutation, subscription, fragment, or SDL schema definition from your editor, API client, or documentation and paste it into the input panel on the left.
- Click Format or use the keyboard shortcut. The formatter runs Prettier's GraphQL parser in your browser and displays the beautified output in the right panel within milliseconds, even for large schemas with hundreds of types.
- Copy and replace. Click the copy button to put the formatted code on your clipboard, then paste it back into your editor, commit it to version control, or share it with a colleague for review.
When formatting GraphQL matters most
Formatting becomes critical during code reviews, when a colleague submits a PR containing a 300-character single-line query that reviewers cannot parse at a glance. It also matters when onboarding new developers, who need to understand an unfamiliar schema quickly. And it matters when debugging: a properly indented query makes it trivial to spot a missing field, an extra brace, or a misspelled argument name.
Teams that adopt a formatter as part of their CI pipeline — running prettier --check on .graphql files — eliminate formatting inconsistencies entirely. ToolJiffy's online formatter is ideal for quick one-off formatting tasks when you're outside your usual development environment: on a shared machine, in a browser-based code review tool, or during a live demonstration.
Explore related developer utilities
After formatting your GraphQL queries, you may also find these tools useful:JSON Formatter for formatting the JSON responses your GraphQL API returns,JavaScript Minifier for shrinking the Apollo or urql client code you ship to users,HTML Formatter for cleaning up server-rendered templates that embed GraphQL data, and SQL Formatter if your GraphQL resolvers contain raw SQL queries that also need beautifying.
Frequently Asked Questions
What does a GraphQL formatter do?
A GraphQL formatter parses your GraphQL document — queries, mutations, subscriptions, or schema definitions — and reprints it with consistent indentation, line breaks, and spacing. The result is code that follows community conventions and is far easier to read, review, and maintain across a team.Which library powers this GraphQL formatter?
ToolJiffy uses Prettier's built-in GraphQL parser, released under the MIT licence. Prettier is the industry-standard opinionated formatter and produces output that matches what most GraphQL projects already expect, so formatted code integrates seamlessly with existing codebases.Does formatting change how a GraphQL query executes?
No. Formatting only affects whitespace, indentation, and line breaks — all of which GraphQL servers completely ignore. Your query, mutation, or schema definition will execute identically before and after formatting. The semantics of the document are preserved exactly.Can I format GraphQL schema definition language (SDL)?
Yes. The formatter handles both executable documents (queries, mutations, subscriptions, fragments) and SDL files (type definitions, interface definitions, input types, directives, enums, unions). Paste any valid GraphQL text and the tool will format it correctly.Why should I name my GraphQL operations?
Named operations (e.g., query GetUserProfile instead of an anonymous query) are essential for server-side logging, APM tracing, and persisted queries. The formatter makes it visually obvious when an operation lacks a name, encouraging the good habit of always naming operations before shipping to production.How does this tool handle GraphQL fragments?
Fragments are formatted with the same indentation rules as queries. The on keyword, spread fields, and nested selections are all aligned consistently. Well-formatted fragments are especially important in large codebases where fragments are shared across many components and files.Is my GraphQL code sent to a server when I format it?
No. All formatting happens entirely inside your browser using a client-side JavaScript bundle. Your schemas, queries, and business logic never leave your machine. This makes the tool safe to use with confidential GraphQL APIs, internal schemas, and proprietary business data.What causes a "GraphQL parse error" in the formatter?
Parse errors occur when the input contains invalid GraphQL syntax — for example, mismatched braces, an unknown keyword, or a malformed directive. Check that every opening brace { has a closing }, that string literals use double quotes, and that field names do not contain spaces or special characters.