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 🙏

© 2026 – Pkg Stats / Ryan Hefner

openapi-to-md

v1.1.1

Published

Convert OpenAPI format to Markdown

Readme

openapi-to-md

Convert OpenAPI (Swagger) specifications into readable Markdown documentation.

Description

openapi-to-md is a tool that transforms OpenAPI v2 and v3 documents (YAML or JSON) into structured Markdown files. This is particularly useful for generating documentation for your APIs that can be easily viewed on GitHub or other Markdown-supported platforms. The output includes TypeScript-style interface definitions for better readability by developers.

Features

  • Multi-version Support: Supports both OpenAPI v2 (Swagger) and v3 formats.
  • Flexible Input: Accepts both JSON and YAML files.
  • Remote Fetching: Can convert files directly from a URL.
  • TypeScript-style Output: Generates data structures resembling TypeScript interfaces.
  • Sorting: Optional alphabetical sorting of paths and references.
  • Safe Handling: Does not deeply resolve recursive references to prevent infinite loops.

CLI Usage

Command Syntax

Usage: openapi-to-md [options] <source> [destination]

Arguments:
  source       Path to the local file or URL of the OpenAPI document
  destination  (Optional) Path to save the generated Markdown file

Options:
  -V, --version  output the version number
  -s, --sort     Sort paths and references alphabetically (default: false)
  -h, --help     display help for command

Examples

Convert a local YAML file and save to README.md:

openapi-to-md openapi.yaml README.md

Convert with sorting enabled:

openapi-to-md -s openapi.yaml README.md

Output to stdout (redirect to file):

openapi-to-md openapi.json > README.md

Convert from a remote URL:

openapi-to-md https://example.com/api-docs.yaml README.md

Programmatic Usage

You can import openapi-to-md into your Node.js or TypeScript project to convert OpenAPI documents programmatically.

Example

import { convertMarkdown } from "openapi-to-md";

const src = `
openapi: 3.0.0
info:
  title: Test API
  version: 1.0.0
paths:
  /test:
    get:
      summary: Get Test
      responses:
        '200':
          description: OK
`;

// Convert the OpenAPI string to Markdown
const markdown = await convertMarkdown(src, true);
console.log(markdown);

API Reference

convertMarkdown(src: string, sort?: boolean): Promise<string | undefined>

| Parameter | Type | Description | | :--- | :--- | :--- | | src | string | The source OpenAPI document content (YAML or JSON string). | | sort | boolean | (Optional) If true, sorts paths and references alphabetically. Default is false. |

Returns: A Promise that resolves to the generated Markdown string. Returns undefined if the input cannot be parsed or an error occurs.

Output Structure

The generated Markdown includes:

  1. Header: Title, Version, and Description from the OpenAPI info object.
  2. Path Table: A summary table of all API endpoints (Method, Path, Summary).
  3. Reference Table: A summary table of all schemas in components or definitions.
  4. Path Details: Detailed information for each endpoint, including parameters, request bodies, and responses.
  5. References: Detailed schema definitions in a TypeScript-like format.

License

MIT