DeveloperKit

GraphQL Formatter

Beautify or minify GraphQL queries, mutations, fragments, and schemas with syntax highlighting. Free, private, and 100% in your browser.

Input GraphQL

1 lines · 0 B

Output

Formatted GraphQL will appear here.

Format GraphQL Queries Online

GraphQL queries copied from network logs, code, or documentation are often squeezed onto one line. The formatter rebuilds the structure: each field on its own line, nested selections indented, and long argument lists split cleanly.

Formatted query
query GetUser($id: ID!) {
  user(id: $id) {
    name
    posts(first: 5) {
      title
    }
  }
}

Features

  • Prettier-style output

    One field per line, nested selections indented, and arguments kept inline until the line gets longer than 80 characters.

  • Queries and schemas

    Formats operations, variables, fragments, directives, and inline fragments, as well as SDL: types, inputs, enums, unions, interfaces, descriptions, and directives.

  • Syntax highlighting

    Keywords, types, variables, directives, strings, and comments are colored for quick reading.

  • Minify for requests

    Remove comments and whitespace to get the smallest query for GET requests, persisted queries, or logs.

  • Clear errors

    Unbalanced braces, parentheses, and brackets and unterminated strings are reported with the exact line and column.

  • Private by design

    Queries and schemas are formatted in your browser and never leave your device.

How to Format GraphQL

  1. Paste a GraphQL query or schema, or upload a .graphql file.
  2. Choose Beautify or Minify and the indentation.
  3. Fix any error shown with its line and column.
  4. Copy or download the result.

Frequently Asked Questions

Are commas required in GraphQL?

No. In GraphQL, commas are optional and treated like whitespace. The formatter adds commas between inline arguments for readability, and leaves them out when arguments are placed on separate lines, like Prettier.

Can I format a GraphQL schema (SDL)?

Yes. Type definitions, inputs, enums, interfaces, unions, scalars, schema definitions, extensions, directive definitions, and descriptions in quotes or triple quotes are all supported.

Does the formatter validate against my schema?

No. It checks the syntax (tokens, strings, and balanced brackets) but not whether fields and types exist in your API. Use your server or an IDE plugin for schema validation.

Why minify a GraphQL query?

Minified queries are smaller in URLs (GET requests), persisted query maps, and logs. The minifier removes comments and unnecessary whitespace without changing the meaning.

  • SQL Formatter

    Beautify long one-line SQL queries and ORM logs into clean, indented, syntax-highlighted SQL, or minify them.

  • Markdown Editor & Previewer

    Write Markdown with a live GitHub-style preview: tables, task lists, code blocks, and alerts. Ideal for README files.

  • JSON Formatter

    Beautify, minify, and validate JSON instantly with exact line and column error reporting.

  • JSON Comparer

    Compare two JSON documents side by side and see every added, removed, and changed value.