express-to-postman
v1.1.3
Published
CLI tool to read an Express.js project and generate a Postman collection JSON
Maintainers
Readme

express-to-postman
Generate Postman Collections automatically from your Express.js application routes.
Features
- Auto-detect Express routes including nested routers
- Supports both JavaScript (ESM/CJS) and TypeScript entry files
- Bundles local route modules while externalizing npm dependencies
- Generates a valid Postman Collection v2.1 JSON file
- Groups routes by first URL segment for better organization
- CLI tool with simple usage and flexible input/output options
Installation
Install globally for system-wide use:
npm install -g express-to-postmanOr add as a dev dependency in your project:
npm install --save-dev express-to-postmanBasic Usage
Run the CLI against your Express app entry point:
express-to-postman -i path/to/your/express/app.js -o output/collection.json-i,--input— Entry file path for your Express app (must exportapp)-o,--output— Output path for the generated Postman collection JSON (default:postman.collection.json)-v,--verbose— Enable verbose logging (default:false)
Detailed Examples
JavaScript (ESM)
Assume your server.js looks like:
import express from 'express';
export const app = express();
app.get('/users', (req, res) => res.json([]));Generate a collection:
express-to-postman -i ./server.js -o ./users-collection.jsonTypeScript
Support for .ts entry files is built-in via on-the-fly transpilation:
import express from 'express';
import router from './routes';
export const app = express();
app.use(router);express-to-postman -i ./src/app.ts -o postman.jsonAdvanced Options
- Auto-detect dependencies: Reads your project’s
package.jsonto externalize all npm packages during bundling. - Custom grouping: Routes are grouped by the first path segment (
/users,/comments). - Verbose logging: Pass
-vor--verboseto print intermediate logs and the full generated collection JSON.
Troubleshooting
- Missing dependencies: If the CLI complains it cannot find a package (e.g.
express), make sure your app’s rootpackage.jsonis detected correctly. The CLI searches upward from your entry file forpackage.json. - Routes not detected: Verify that your Express app exports a named
appand that routes are registered beforeapp.listen().
Configuration
You can also import and use generateCollection() programmatically in Node:
import { generateCollection } from 'express-to-postman';
(async () => {
await generateCollection(
'./dist/app.js',
'./collection.json',
true // verbose
);
})();