
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
postman-collection-transformer
Advanced tools
Perform rapid conversation and validation of JSON structure between Postman Collection Format v1 and v2
Perform rapid conversion of JSON structure between Postman Collection Format v1 and v2.
The formats are documented at https://schema.postman.com
For CLI usage:
$ npm install -g postman-collection-transformer
As a library:
$ npm install --save postman-collection-transformer
The transformer provides a Command line API to convert collections.
Example:
$ postman-collection-transformer convert \
--input ./v1-collection.json \
--input-version 2.0.0 \
--output ./v2-collection.json \
--output-version 1.0.0 \
--pretty \
--overwrite
All options:
$ postman-collection-transformer convert -h
Usage: convert [options]
Convert Postman Collection from one format to another
Options:
-h, --help output usage information
-i, --input <path> path to the input postman collection file
-j, --input-version [version] the version of the input collection format standard (v1 or v2)
-o, --output <path> target file path where the converted collection will be written
-p, --output-version [version] required version to which the collection is needed to be converted to
-P, --pretty Pretty print the output
--retain-ids Retain the request and folder IDs during conversion (collection ID is always retained)
-w, --overwrite Overwrite the output file if it exists
If you'd rather use the transformer as a library:
var transformer = require('postman-collection-transformer'),
collection = require('./path/to/collection.json'),
inspect = require('util').inspect,
options = {
inputVersion: '1.0.0',
outputVersion: '2.0.0',
retainIds: true // the transformer strips request-ids etc by default.
};
transformer.convert(collection, options, function (error, result) {
if (error) {
return console.error(error);
}
// result <== the converted collection as a raw Javascript object
console.log(inspect(result, {colors: true, depth: 10000}));
});
The transformer also allows you to convert individual requests (only supported when used as a library):
var transformer = require('postman-collection-transformer'),
objectToConvert = { /* A valid collection v1 Request or a collection v2 Item */ },
options = {
inputVersion: '1.0.0',
outputVersion: '2.0.0',
retainIds: true // the transformer strips request-ids etc by default.
};
transformer.convertSingle(objectToConvert, options, function (err, converted) {
console.log(converted);
});
You can convert individual responses too if needed:
var transformer = require('postman-collection-transformer'),
objectToConvert = { /* A v1 Response or a v2 Response */ },
options = {
inputVersion: '1.0.0',
outputVersion: '2.0.0',
retainIds: true // the transformer strips request-ids etc by default.
};
transformer.convertResponse(objectToConvert, options, function (err, converted) {
console.log(converted);
});
The transformer also provides a Command line API to normalize collections for full forward compatibility.
Example:
$ postman-collection-transformer normalize \
--input ./v1-collection.json \
--normalize-version 1.0.0 \
--output ./v1-norm-collection.json \
--pretty \
--overwrite
All options:
$ postman-collection-transformer normalize -h
Usage: normalize [options]
Normalizes a postman collection according to the provided version
Options:
-i, --input <path> Path to the collection JSON file to be normalized
-n, --normalize-version <version> The version to normalizers the provided collection on
-o, --output <path> Path to the target file, where the normalized collection will be written
-P, --pretty Pretty print the output
--retain-ids Retain the request and folder IDs during conversion (collection ID is always retained)
-w, --overwrite Overwrite the output file if it exists
-h, --help Output usage information
If you'd rather use the transformer as a library:
var transformer = require('postman-collection-transformer'),
collection = require('./path/to/collection.json'),
inspect = require('util').inspect,
options = {
normalizeVersion: '1.0.0',
mutate: false, // performs in-place normalization, false by default.
noDefaults: false, // when set to true, sensible defaults for missing properties are skipped. Default: false
prioritizeV2: false, // when set to true, v2 attributes are used as the source of truth for normalization.
retainEmptyValues: false, // when set to true, empty values are set to '', not removed. False by default.
retainIds: true // the transformer strips request-ids etc by default.
};
transformer.normalize(collection, options, function (error, result) {
if (error) {
return console.error(error);
}
// result <== the converted collection as a raw Javascript object
console.log(inspect(result, {colors: true, depth: 10000}));
});
The postman-collection package provides a set of utilities for working with Postman collections, including creating, manipulating, and validating collections. While it offers some transformation capabilities, it is more focused on general collection management compared to the specialized transformation features of postman-collection-transformer.
The swagger-jsdoc package allows you to generate Swagger (OpenAPI) documentation from JSDoc comments in your code. While it is not specifically for Postman collections, it serves a similar purpose of transforming API documentation formats. It is more focused on generating documentation rather than transforming between different collection versions.
The openapi-to-postmanv2 package converts OpenAPI (Swagger) definitions to Postman collections. It is similar to postman-collection-transformer in that it deals with transforming API documentation formats, but it specifically focuses on converting OpenAPI specs to Postman collections rather than transforming between different Postman collection versions.
FAQs
Perform rapid conversation and validation of JSON structure between Postman Collection Format v1 and v2
The npm package postman-collection-transformer receives a total of 564,250 weekly downloads. As such, postman-collection-transformer popularity was classified as popular.
We found that postman-collection-transformer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.