External Libraries
Bruno allows you to load any npm module or package for use in your scripting workflows.
Prerequisites
Before you begin, ensure that you have the following:
- Node.js installed on your system.
- Bruno installed.
Project structure
The folder structure depends on your collection format.
Configuration
You need a package.json file at the root of your Bruno collection.
- Open your collection folder in Bruno or in an editor such as VS Code.
- Open the integrated terminal (in Bruno or your editor) and go to the collection root:
cd path/to/your/bruno-collection
- Initialize
package.json:
npm init -y
- Install the package (run this in the same terminal, from the collection root):
npm install csv-parse
- Confirm
csv-parseappears underdependenciesinpackage.json, for example:
"dependencies": {
"csv-parse": "^6.2.1"
}
Exact versions may differ, but what matters is that the dependency is listed after a successful install.
- In Bruno, enable Developer Mode for the collection so
require()can load packages fromnode_modules.
Example: Parse CSV with csv-parse
This example uses csv-parse ↗ to turn CSV text into JavaScript objects, then sends the first row as JSON on the request. See the npm package page ↗ for options, streaming APIs, and more.
Use a Pre Request script with Developer Mode on:
const { parse } = require('csv-parse/sync');
const csvData = `name,email
Smith,smith@example.com
John,john@example.com`;
const records = parse(csvData, {
columns: true,
skip_empty_lines: true
});
req.setHeader('Content-Type', 'application/json');
req.setBody(records[0]);

records[0] is the first data row as an object (for example { name: 'Smith', email: 'smith@example.com' }) because columns: true uses the first line as headers.
Reading CSV from a file
You can also pass CSV from a file in your collection (path is relative to the collection root):
const fs = require('fs');
const path = require('path');
const { parse } = require('csv-parse/sync');
const csvData = fs.readFileSync(path.join(__dirname, 'data.csv'), 'utf8');
const records = parse(csvData, {
columns: true,
skip_empty_lines: true
});
req.setHeader('Content-Type', 'application/json');
req.setBody(records[0]);
Adjust the path to match where you store your .csv file.