New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

openapi-minifier

Package Overview
Dependencies
Maintainers
5
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-minifier

A CLI tool by Treblle tp minify OpenAPI V3 Specs by removing redundant information not relevant to AI Agents and LLMs.

latest
npmnpm
Version
1.0.2
Version published
Maintainers
5
Created
Source

Treblle - API Intelligence Platform

Treblle API Intelligence

WebsiteDocumentationPricing

Treblle is an API intelligence platfom that helps developers, teams and organizations understand their APIs from a single integration point.

OpenAPI Minifier CLI

Latest Version Total Downloads MIT Licence

🧹 A CLI tool that compresses OpenAPI Specification files by up to 80% while preserving all essential details for understanding and integrating the API. Perfect for AI agents and LLMs as it drastically reduces token usage without sacrificing functionality.

Requirements

  • OpenAPI Specification Version 3.X

Features

  • JSON & YAML: Supports both input and output formats
  • Large File Support: Efficiently handles multi-MB specification files
  • Easy To Use Presets: Choose from max, balanced, or min presets
  • Deprecated Path Removal: Remove unused and deprecated endpoints
  • Schema Extraction: Extract inlined schemas into reusable components
  • Smart Minification: Removes verbose elements while preserving API functionality
  • Advanced Optimizations: Schema cleanup, unused component removal, and JSON minification
  • Developer Friendly: Detailed statistics and CLI friendly UI

Installation

npm install -g openapi-minifier

Or use directly with npx:

npx openapi-minifier input.json

Usage

Basic Usage

openapi-minifier input.json
openapi-minifier input.yaml -o output.yaml

Presets

# Maximum reduction (recommended for AI/LLMs)
openapi-minifier input.json --preset max

# Balanced approach (keeps schema descriptions)
openapi-minifier input.json --preset balanced

# Minimal reduction (preserves documentation)
openapi-minifier input.json --preset min

Advanced Options

openapi-minifier input.json \
  --output output.json \
  --preset balanced \
  --keep-examples \
  --keep-descriptions schema-only \
  --remove-deprecated \
  --extract-common-responses \
  --validate \
  --format json

CLI Options

Options:
  -V, --version                        output the version number
  -o, --output <file>                  Output file path
  --preset <preset>                    Minification preset: max, balanced, min (default: "balanced")
  --keep-examples                      Keep example values (default: false)
  --keep-descriptions <mode>           Description handling: all, schema-only, none (default: "schema-only")
  --keep-summaries                     Keep summary fields (default: false)
  --keep-tags                          Keep tag descriptions (default: false)
  --remove-deprecated                  Remove deprecated paths and operations (default: false)
  --extract-common-responses           Extract common responses to components/responses (default: false)
  --extract-common-schemas             Extract common schemas to components/schemas (default: false)
  --validate                           Enable OpenAPI validation (default: false)
  --format <format>                    Output format: json, yaml (default: "json")
  -h, --help                           display help for command

Presets

PresetExamplesDescriptionsSchema CleanupRemove DeprecatedExtract ComponentsSize ReductionUse Case
max❌ Remove❌ Remove all✅ Aggressive✅ Remove✅ Extract🔥 ~78%Best for AI/LLMs
balanced❌ Remove📄 Schema only✅ Conservative✅ Remove✅ Extract🔥 ~67%Recommended default
min✅ Keep✅ Keep all❌ None❌ Keep❌ No extraction~0%Preserve documentation

What Gets Removed

  • JSON minification: Remove all whitespace from JSON output
  • Unused schemas: Remove unreferenced component schemas
  • Schema properties: Remove validation constraints (format, pattern, minLength, etc.)
  • Examples: All request/response example bodies
  • Descriptions: Verbose operation and parameter descriptions
  • Summaries: Operation summary fields
  • Tag descriptions: Keep tag names, remove descriptions

Example Results

Test results using sample OpenAPI specifications included in this repository:

Jira API (2.5 MB)

PresetOutput SizeReductionExamplesDescriptionsSummariesTagsDeprecatedExtracted
max767 KB69.4%0 removed3,116 removed498 removed13 removed4 removed1,262 total
balanced1,021 KB59.3%0 removed725 removed498 removed13 removed4 removed1,262 total
min1.6 MB35.0%0 removed0 removed0 removed0 removed0 removed0 total

Stripe API (6.7 MB)

PresetOutput SizeReductionExamplesDescriptionsSummariesTagsDeprecatedExtracted
max1.8 MB72.4%0 removed8,315 removed546 removed0 removed2 removed993 total
balanced2.8 MB57.6%0 removed862 removed546 removed0 removed2 removed993 total
min3.2 MB51.8%0 removed0 removed0 removed0 removed0 removed0 total

OpenAPI Sample (1.9 MB)

PresetOutput SizeReductionExamplesDescriptionsSummariesTagsDeprecatedExtracted
max446 KB77.2%162 removed3,328 removed164 removed0 removed0 removed99 total
balanced686 KB64.9%162 removed844 removed164 removed0 removed0 removed99 total
min1.4 MB25.6%0 removed0 removed0 removed0 removed0 removed0 total

Support

If you have problems of any kind feel free to reach out via https://treblle.com or email support@treblle.com and we'll do our best to help you out.

License

Copyright 2025, Treblle Inc. Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php

Keywords

openapi

FAQs

Package last updated on 10 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts