GraphQL Compressor
Compress GraphQL schema and query documents online for free by removing comments, blank lines, and whitespace. Our GraphQL compressor correctly handles block string descriptions and supports a single-line collapse mode for generating persisted query IDs. Shows wire-size savings and line count reduction. All processing happens in your browser — your schema never leaves your device. No signup required.
Compression Options
Why Use Our GraphQL Compressor?
Instant GraphQL Compression
Compress any GraphQL schema or query document in milliseconds. Our GraphQL compressor processes everything locally in your browser — no upload wait, no server round-trip, zero latency.
Secure GraphQL Compressor Online
Your GraphQL schema and queries never leave your device when you compress them. 100% client-side processing means complete privacy — no cloud storage, no server logs, no data exposure.
GraphQL Compressor Online — No Installation
Compress GraphQL directly in your browser. No software downloads, no plugins, no account required. Works on any modern browser on any operating system.
Single-Line Mode for Persisted Queries
Enable "Collapse to Single Line" to produce the most compact possible GraphQL string — ideal for generating persisted query IDs, embedding queries in HTTP GET parameters, and reducing wire-transfer size.
Common Use Cases for GraphQL Compressor
Persisted Query Generation
Compress GraphQL queries to a single line before hashing them for persisted query IDs. Apollo Client, Relay, and other GraphQL clients use the compressed query string as the input to SHA-256 hashing for automatic persisted queries (APQ).
API Wire-Size Reduction
Compress GraphQL query documents before sending them in HTTP request bodies or GET parameters. Removing whitespace and comments from a typical GraphQL query can reduce payload size by 30–60%, improving API response times.
Schema Registry Optimization
Compress GraphQL SDL schemas before uploading to schema registries like Apollo Studio, Hasura, or custom schema stores. Smaller schema files reduce storage costs and speed up schema validation pipelines.
Query Storage Compression
Compress GraphQL queries before storing them in databases, Redis caches, or configuration files. Removing comments and whitespace reduces storage size and speeds up query retrieval in high-throughput GraphQL servers.
Code Generation Preprocessing
Compress GraphQL schema files before feeding them into code generation tools like GraphQL Code Generator, Pothos, or TypeGraphQL. Smaller input files speed up code generation and reduce intermediate artifact sizes.
Documentation-Stripped Schemas
Create documentation-stripped versions of GraphQL SDL schemas for internal builds where introspection descriptions are not needed. Remove block string descriptions (""") to produce a minimal schema for runtime use.
Understanding GraphQL Compression
What is GraphQL Compression?
GraphQL compression is the process of reducing the byte size of a GraphQL document — either a Schema Definition Language (SDL) file or a query/mutation/subscription document — by removing content that is not required for parsing or execution. This includes # comments, blank lines, trailing whitespace, and optionally block string descriptions ("""..."""). Our GraphQL compressoruses a tokenizer that correctly identifies block strings and regular strings, ensuring their content is never modified. The "Collapse to Single Line" mode produces the most compact possible output — the standard format used for Automatic Persisted Queries (APQ) in Apollo Client and Relay.
How Our GraphQL Compressor Works
- 1Paste or upload your GraphQL: Enter any GraphQL SDL schema or query document in the input panel, or upload a .graphql, .gql, or .graphqls file. Configure which elements to remove using the option toggles.
- 2Instant browser-based compression:Click "Compress GraphQL". The document is tokenized to identify strings, block strings, and comments — then each enabled pass runs locally in your browser with no data sent to any server.
- 3Copy or download the compressed GraphQL: Copy the output to clipboard or download as a .graphql file. The output is valid GraphQL that any GraphQL parser can process directly.
What Gets Removed
- Comments (
#): All# commentlines are stripped. GraphQL uses#for line comments — they are never required for schema or query execution. - Blank Lines: Empty lines and whitespace-only lines between definitions are stripped. These are common in well-formatted SDL schemas and query documents.
- Block String Descriptions (
"""..."""): When "Remove Descriptions" is enabled, block string descriptions used for SDL documentation are removed. Disable this option when the schema is used for introspection or documentation generation. - Whitespace Normalization: Multiple consecutive spaces are collapsed to a single space, and whitespace around GraphQL punctuation (braces, colons, pipes) is normalized. In single-line mode, all whitespace is collapsed to the minimum required.
Persisted Queries and Single-Line Mode
Automatic Persisted Queries (APQ) work by sending a SHA-256 hash of the query string instead of the full query on subsequent requests. The hash must be computed from the exact same stringthat the server has cached. The standard approach is to compress the query to a single line (removing all unnecessary whitespace) before hashing. Enable "Collapse to Single Line" to produce the canonical single-line format used by Apollo Client's print(parse(query)) normalization. This ensures your client and server compute identical hashes for the same logical query.
Related Tools
JSON Key Shortener
Shorten verbose JSON keys to single letters or abbreviated forms — shows size reduction and provides a downloadable key mapping file for restoration. Free online JSON key shortener.
JSON vs MessagePack Size Comparison
Compare JSON byte size vs MessagePack encoding for any payload — shows exact savings, type-by-type breakdown, and MessagePack hex preview. Free online JSON vs MessagePack comparison.
String Decompressor (GZIP/LZ)
Decompress GZIP+Base64, DEFLATE+Base64, and LZ-String compressed payloads back to readable text — supports all three LZ-String variants. Free online string decompressor.
ZIP File Extractor
Extract files from any ZIP archive client-side — browse contents, preview text files, download individual files or all at once. Free online ZIP extractor, no signup required.
Frequently Asked Questions About GraphQL Compressor
A GraphQL compressor is a tool that reduces the byte size of a GraphQL schema (SDL) or query document by removing comments, blank lines, and whitespace — producing a smaller but still valid GraphQL document. Our free GraphQL compressor online works entirely in your browser with no server upload.
Yes. The compressor only removes comments, blank lines, and whitespace — it never modifies type names, field names, directives, or string values. The output is valid GraphQL that any GraphQL parser (graphql-js, graphql-core, etc.) can parse and execute correctly.
Absolutely. Our GraphQL compressor processes everything locally in your browser. Your schema and queries are never uploaded to any server, never stored, and never leave your device. All compression happens entirely on your machine.
Yes — 100% free, forever. No signup, no account, no premium tier, no file size limits, and no ads interrupting your workflow. Just paste your GraphQL, compress, and copy the output.
Single-line mode collapses the entire GraphQL document to a single line with minimal whitespace — the standard format for Automatic Persisted Queries (APQ). Use it when you need to hash a query string for APQ, embed a query in a URL GET parameter, or store queries in a format that requires a single-line string.
Block string descriptions ("""...""") are multi-line strings used in SDL schemas to document types, fields, and arguments — they appear in GraphQL introspection results and are used by tools like GraphQL Playground and Apollo Studio. Keep them when the schema is used for introspection or documentation. Remove them only for runtime-only schemas where documentation is not needed.
Yes. The compressor works with any valid GraphQL document — SDL type definitions (type, interface, union, enum, input, scalar, directive), query/mutation/subscription operations, fragments, and inline fragments. All GraphQL document types are supported.
Typical GraphQL compression achieves 20–60% size reduction depending on how many comments and blank lines the original document contains. Well-documented SDL schemas with extensive block string descriptions and inline comments compress most aggressively when description removal is enabled.
Since compression runs entirely in your browser, the practical limit depends on your device's available RAM. Most modern devices handle GraphQL files up to several megabytes without issues. For very large generated schemas, ensure you have sufficient memory available.