Shipping a well-documented API can feel like a second job. You build your Express routes, then spend even more time hand-crafting Postman collections so teammates and QA can exercise your endpoints.
What if you could generate that collection automaticallyβwithout extra config, manual exports, or tedious copy-pasting?
Enter express-to-postman, a zero-config CLI that introspects your running Express app (JS or TS), bundles up all your local route modules, and spits out a fully valid Postman v2.1 collectionβgrouped by URL segment and ready to import.
π Key Benefits
Instant Collection Generation
Point the CLI at your entry file (app.js
orapp.ts
) and get a complete Postman JSON in one command.Zero Boilerplate
No decorators or special annotationsβjust your normalapp.get()
/router.use()
calls.TypeScript-Ready
Transpiles.ts
on the fly, bundles your local modules, and externalizes your npm deps automatically.Organized Output
Routes are grouped by their first path segment (/users
,/comments
, etc.), so your collection stays tidy.CLI & Programmatic
Use it from the terminal or integrategenerateCollection()
into your build scripts, CI pipelines, or docs generator.
π― How It Works
Bundle Your App
Under the hood,express-to-postman
uses [esbuild] to bundle all local.js
/.ts
files into a single temporary ESM module. External npm packages (likeexpress
,cors
, etc.) remain as imports.Introspect Routes
It dynamically imports that bundle, walks through the Express router stack, and extracts every routeβs path and HTTP methodβeven those nested under sub-routers.Emit Postman JSON
It then constructs a v2.1 Postman Collection, grouping items by first path segment, and writes it to your chosen output file.
β¨ Quick Start
# Install globally
npm install -g express-to-postman
# Generate a collection in one go
express-to-postman \
-i ./src/app.ts \
-o ./postman.collection.json
# Or as a dev dependency & npm script
npm install --save-dev express-to-postman
# package.json
"scripts": {
"postman": "express-to-postman -i ./src/server.js -o ./collections/api.json"
}
π Example
Given this simple app.ts
:
import express from 'express'
import userRouter from './routes/users'
export const app = express()
app.use('/users', userRouter)
app.get('/', (_req, res) => res.send('OK'))
Running:
express-to-postman -i src/app.ts -o postman.json
Produces a JSON with two foldersβusers
and /
βand three requests:
GET /users
POST /users/:id
GET /
All ready for import into Postman or Newman.
π§ Advanced Tips
-
Verbose Mode: Add
-v
to see intermediate logs and the full JSON in your terminal. -
CI Integration: Run
express-to-postman
in your pipeline to always ship up-to-date API collections. - Programmatic Use:
import { generateCollection } from 'express-to-postman'
await generateCollection('./dist/app.js', './api.postman.json', true)
π Try It Today!
Stop spending hours maintaining Postman collections by hand. Install express-to-postman
in seconds and let it keep your API docs in sync with your code.
npm install -g express-to-postman
If you found this helpful, feel free to share
Letβs connect!!: π€
Top comments (4)
I built express-to-postman to save you hours of manual Postman-collection maintenanceβlet me know how it fits into your workflow!
π Repo & Docs: github.com/your-username/express-t...
π¬ Iβm eager to hear your feedback or any feature requests (auth detection, custom grouping, examples). Drop a line below or open an issue on GitHub!
pretty cool tbh, been burned too many times by out-of-date docs. you think devs ignore stuff like this because the old way feels safer or they just get stuck in habits?
manually writing docs can feel safer since you control the details and avoid auto-generated errors or outdated info.
Some comments may only be visible to logged-in visitors. Sign in to view all comments.