npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

openapi-to-llm-text

v1.1.0

Published

Convert OpenAPI specifications to LLM-optimized text

Readme

openapi-to-llm-text

Convert OpenAPI specifications to LLM-optimized text.

Overview

This library transforms OpenAPI specifications (OpenAPI 2.0, 3.0, and 3.1) into a concise, structured text format optimized for Large Language Model (LLM) consumption. It extracts API endpoints, schemas, security configurations, and other relevant information into an easy-to-parse text format.

Installation

npm install openapi-to-llm-text

Usage

import { openApiToLlmText } from 'openapi-to-llm-text';
import { readFileSync } from 'fs';

// Load your OpenAPI spec
const openApiSpec = JSON.parse(readFileSync('path/to/openapi.json', 'utf-8'));

// Convert to text
const text = openApiToLlmText(openApiSpec);

console.log(text);

For YAML files:

import { openApiToLlmText } from 'openapi-to-llm-text';
import { readFileSync } from 'fs';
import { parse } from 'yaml';

const openApiSpec = parse(readFileSync('path/to/openapi.yaml', 'utf-8'));
const text = openApiToLlmText(openApiSpec);

Output Format

The generated text includes:

  • API Information: Title, version, description, and base URL
  • Endpoints: All HTTP methods with summaries, parameters, request bodies, and responses
  • Schemas: Data models with property types and requirements
  • Security: Authentication schemes (OAuth2, API Key, HTTP Bearer, etc.)

Example Output

API: Swagger Petstore - OpenAPI 3.0 v1.0.27
Description: This is a sample Pet Store Server...

Base URL: /api/v3

ENDPOINTS:

GET /pet/{petId}
  Summary: Find pet by ID
  Parameters:
    - petId (path, integer (required)): ID of pet to return
  Responses:
    200: Successful operation
      Content: application/json
      Schema: Pet

SCHEMAS:

Pet:
  - id: integer (format: int64)
  - name: string (required)
  - status: string

SECURITY:
- API Key authentication (header: api_key)

Features

  • ✅ Supports OpenAPI 3.0 and 3.1
  • ✅ Handles references, compositions (allOf, oneOf, anyOf)
  • ✅ Extracts schema properties with required fields
  • ✅ Formats arrays and nested objects
  • ✅ Includes all HTTP methods (GET, POST, PUT, DELETE, PATCH, etc.)
  • ✅ Captures security schemes

Development

# Install dependencies
pnpm install

# Run tests
pnpm test

# Build
pnpm build

# Watch tests
pnpm test:watch

License

MIT