gqlmin is a lightweight (<1 kB, ~3.4 kB gzip with dependency) GraphQL query minifier that removes insignificant whitespace and comments from GraphQL queries. Version 0.3.2 is current, stable, and maintained. It offers both a runtime ESM API and a CLI for build-time use. Unlike alternatives that bundle validation, gqlmin prioritizes minimal size and performance, assuming queries are pre-validated. It's ideal for reducing payload size in large GraphQL apps or optimizing GET requests for caching.
npm install gqlminNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Minifies a GraphQL query by stripping whitespace and comments, using the default import from gqlmin.
Use dynamic import(): const gqlmin = await import('gqlmin');Validate queries with a GraphQL validator before minifying.
Ensure comments are not needed after minification.
Consider if the size overhead is acceptable for your use case.
Use forward slashes or escape paths appropriately.
Use dynamic import: const gqlmin = await import('gqlmin');Use: import gqlmin from 'gqlmin';
Pre-validate the GraphQL query with a parser like graphql's parse() before minifying.
Run: npm install gqlmin (will install moo as a dependency).