Files
bruno/packages/bruno-converters
sanish chirayath 2bbfb28090 fix: handle falsy values in Postman environment and collection variables (#4924)
* fix: handle falsy values in Postman environment and collection variables

* Updated the `postman-env-to-bruno-env` and `postman-to-bruno` converters to handle cases where variable keys or values are falsy, ensuring they default to empty strings.
* Added unit tests to verify the correct handling of falsy values in both environment and collection variables.

* fix: filter out null/undefined keys and values in Postman variable imports

* Updated the `postman-env-to-bruno-env` and `postman-to-bruno` converters to filter out variables with null keys and values during import.
* Removed redundant test cases for empty variables in the corresponding unit tests.
2025-06-24 15:58:29 +05:30
..
2025-04-10 03:55:30 +05:30

bruno-converters

The converters package is responsible for converting collections from one format to a Bruno collection. It can be used as a standalone package or as a part of the Bruno framework.

Installation

npm install @usebruno/converters

Usage

Convert Postman collection to Bruno collection

const { postmanToBruno } = require('@usebruno/converters');

// Convert Postman collection to Bruno collection
const brunoCollection = postmanToBruno(postmanCollection);

Convert Postman Environment to Bruno Environment

const { postmanToBrunoEnvironment } = require('@usebruno/converters');

const brunoEnvironment = postmanToBrunoEnvironment(postmanEnvironment);

Convert Insomnia collection to Bruno collection

import { insomniaToBruno } from '@usebruno/converters';

const brunoCollection = insomniaToBruno(insomniaCollection);

Convert OpenAPI specification to Bruno collection

import { openApiToBruno } from '@usebruno/converters';

const brunoCollection = openApiToBruno(openApiSpecification);

Example


const { postmanToBruno } = require('@usebruno/converters');
const fs = require('fs/promises');
const path = require('path');

async function convertPostmanToBruno(inputFile, outputFile) {
  try {
    // Read Postman collection file
    const inputData = await fs.readFile(inputFile, 'utf8');
    
    // Convert to Bruno collection
    const brunoCollection = postmanToBruno(JSON.parse(inputData));
    
    // Save Bruno collection
    await fs.writeFile(outputFile, JSON.stringify(brunoCollection, null, 2));
    
    console.log('Conversion successful!');
  } catch (error) {
    console.error('Error during conversion:', error);
  }
}

// Usage
const inputFilePath = path.resolve(__dirname, 'demo_collection.postman_collection.json');
const outputFilePath = path.resolve(__dirname, 'bruno-collection.json');

convertPostmanToBruno(inputFilePath, outputFilePath);