npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

curl2vro

v2.0.2

Published

Convert curl commands to vRO JavaScript code

Readme

curl2vRO

npm version License: MIT Downloads GitHub stars

A utility to convert curl commands to VMware vRealize Orchestrator (vRO) JavaScript code.

Requirements

  • Node.js 14.x or higher
  • VMware vRealize Orchestrator environment for running the generated code
  • npm 6.x or higher

Table of Contents

Installation

npm install curl2vro

Usage

const curl2vRO = require('curl2vRO');

// Your curl command
const curlCommand = `curl https://api.example.com/data`;

// Convert to vRO code
const vroCode = curl2vRO.convertCurlToVRO(curlCommand);
console.log(vroCode);

The tool will generate a JavaScript file with the vRO code and save it in the current directory. The filename is derived from the hostname, path, and HTTP method.

Features

  • Converts curl commands to vRO JavaScript code
  • Supports various HTTP methods (GET, POST, PUT, DELETE, etc.)
  • Handles request headers
  • Processes request body data (JSON, form data)
  • Automatically generates appropriate filenames
  • Adds JSDoc documentation to generated code
  • Includes original curl command as a comment for reference

Examples

Basic GET Request

// Input
const curlCommand = `curl -X GET https://api.sampleapis.com/coffee/hot`;

// Output
/**
 * @description Curl to vRO JavaScript converted code
 * @author curl2vRO (Mayank Goyal)
 */

// Accept SSL certificate
var ld = Config.getKeystores().getImportCAFromUrlAction();
var model = ld.getModel();
model.value = "https://api.sampleapis.com/coffee/hot";
var error = ld.execute();
if (error) {
    throw new Error("Failed to accept certificate for URL: " + "https://api.sampleapis.com/coffee/hot" + ". Error: " + error);
}

// Create transient REST host
var restHost = RESTHostManager.createHost("dynamicRequest");
var httpRestHost = RESTHostManager.createTransientHostFrom(restHost);
httpRestHost.operationTimeout = 600;
httpRestHost.url = "https://api.sampleapis.com";

// Create REST request
var request = httpRestHost.createRequest("GET", "/coffee/hot", null);

// Execute REST request
var response = request.execute();

// Handle response
if (response.statusCode == 200) {
    System.log("Request successful");
    var responseContent = JSON.parse(response.contentAsString);
    System.log(JSON.stringify(responseContent));
} else {
    throw "Request failed with status: " + response.statusCode;
}

/*
Original curl command:
curl -X GET https://api.sampleapis.com/coffee/hot
*/

POST Request with JSON Body

// Input
const curlCommand = `curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer token123" \
  -d '{"name": "John Doe", "email": "[email protected]"}'`;

// Output
/**
 * @description Curl to vRO JavaScript converted code
 * @author curl2vRO (Mayank Goyal)
 */

// Accept SSL certificate
var ld = Config.getKeystores().getImportCAFromUrlAction();
var model = ld.getModel();
model.value = "https://api.example.com/users";
var error = ld.execute();
if (error) {
    throw new Error("Failed to accept certificate for URL: " + "https://api.example.com/users" + ". Error: " + error);
}

// Create transient REST host
var restHost = RESTHostManager.createHost("dynamicRequest");
var httpRestHost = RESTHostManager.createTransientHostFrom(restHost);
httpRestHost.operationTimeout = 600;
httpRestHost.url = "https://api.example.com";

// Create REST request
var request = httpRestHost.createRequest("POST", "/users", JSON.stringify({"name": "John Doe", "email": "[email protected]"}));

// Add headers
request.setHeader("Content-Type", "application/json");
request.setHeader("Authorization", "Bearer token123");

// Execute REST request
var response = request.execute();

// Handle response
if (response.statusCode == 200) {
    System.log("Request successful");
    var responseContent = JSON.parse(response.contentAsString);
    System.log(JSON.stringify(responseContent));
} else {
    throw "Request failed with status: " + response.statusCode;
}

/*
Original curl command:
curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer token123" \
  -d '{"name": "John Doe", "email": "[email protected]"}'
*/

PUT Request with Authentication

// Input
const curlCommand = `curl --location --request PUT 'https://api.example.com/resources/123' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic dXNlcjpwYXNzd29yZA==' \
--data-raw '{
    "title": "Updated Resource",
    "status": "active",
    "priority": 1
}'`;

// Output
/**
 * @description Curl to vRO JavaScript converted code
 * @author curl2vRO (Mayank Goyal)
 */

// Accept SSL certificate
var ld = Config.getKeystores().getImportCAFromUrlAction();
var model = ld.getModel();
model.value = "https://api.example.com/resources/123";
var error = ld.execute();
if (error) {
    throw new Error("Failed to accept certificate for URL: " + "https://api.example.com/resources/123" + ". Error: " + error);
}

// Create transient REST host
var restHost = RESTHostManager.createHost("dynamicRequest");
var httpRestHost = RESTHostManager.createTransientHostFrom(restHost);
httpRestHost.operationTimeout = 600;
httpRestHost.url = "https://api.example.com";

// Create REST request
var request = httpRestHost.createRequest("PUT", "/resources/123", JSON.stringify({
    "title": "Updated Resource",
    "status": "active",
    "priority": 1
}));

// Add headers
request.setHeader("Content-Type", "application/json");
request.setHeader("Authorization", "Basic dXNlcjpwYXNzd29yZA==");

// Execute REST request
var response = request.execute();

// Handle response
if (response.statusCode == 200) {
    System.log("Request successful");
    var responseContent = JSON.parse(response.contentAsString);
    System.log(JSON.stringify(responseContent));
} else {
    throw "Request failed with status: " + response.statusCode;
}

/*
Original curl command:
curl --location --request PUT 'https://api.example.com/resources/123' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic dXNlcjpwYXNzd29yZA==' \
--data-raw '{
    "title": "Updated Resource",
    "status": "active",
    "priority": 1
}'
*/

DELETE Request

// Input
const curlCommand = `curl -X DELETE https://api.example.com/users/123 \
  -H "Authorization: Bearer token123"`;

// Output
/**
 * @description Curl to vRO JavaScript converted code
 * @author curl2vRO (Mayank Goyal)
 */

// Accept SSL certificate
var ld = Config.getKeystores().getImportCAFromUrlAction();
var model = ld.getModel();
model.value = "https://api.example.com/users/123";
var error = ld.execute();
if (error) {
    throw new Error("Failed to accept certificate for URL: " + "https://api.example.com/users/123" + ". Error: " + error);
}

// Create transient REST host
var restHost = RESTHostManager.createHost("dynamicRequest");
var httpRestHost = RESTHostManager.createTransientHostFrom(restHost);
httpRestHost.operationTimeout = 600;
httpRestHost.url = "https://api.example.com";

// Create REST request
var request = httpRestHost.createRequest("DELETE", "/users/123", null);

// Add headers
request.setHeader("Authorization", "Bearer token123");

// Execute REST request
var response = request.execute();

// Handle response
if (response.statusCode == 200) {
    System.log("Request successful");
    var responseContent = JSON.parse(response.contentAsString);
    System.log(JSON.stringify(responseContent));
} else {
    throw "Request failed with status: " + response.statusCode;
}

/*
Original curl command:
curl -X DELETE https://api.example.com/users/123 \
  -H "Authorization: Bearer token123"
*/

Request with Query Parameters

// Input
const curlCommand = `curl "https://api.example.com/search?q=test&limit=10" \
  -H "Accept: application/json"`;

// Output
/**
 * @description Curl to vRO JavaScript converted code
 * @author curl2vRO (Mayank Goyal)
 */

// Accept SSL certificate
var ld = Config.getKeystores().getImportCAFromUrlAction();
var model = ld.getModel();
model.value = "https://api.example.com/search?q=test&limit=10";
var error = ld.execute();
if (error) {
    throw new Error("Failed to accept certificate for URL: " + "https://api.example.com/search?q=test&limit=10" + ". Error: " + error);
}

// Create transient REST host
var restHost = RESTHostManager.createHost("dynamicRequest");
var httpRestHost = RESTHostManager.createTransientHostFrom(restHost);
httpRestHost.operationTimeout = 600;
httpRestHost.url = "https://api.example.com";

// Create REST request
var request = httpRestHost.createRequest("GET", "/search?q=test&limit=10", null);

// Add headers
request.setHeader("Accept", "application/json");

// Execute REST request
var response = request.execute();

// Handle response
if (response.statusCode == 200) {
    System.log("Request successful");
    var responseContent = JSON.parse(response.contentAsString);
    System.log(JSON.stringify(responseContent));
} else {
    throw "Request failed with status: " + response.statusCode;
}

/*
Original curl command:
curl "https://api.example.com/search?q=test&limit=10" \
  -H "Accept: application/json"
*/

API Reference

convertCurlToVRO(curlCommand)

Converts a curl command to vRO JavaScript code and saves it to a file.

  • Parameters
    • curlCommand (string): The curl command to convert
  • Returns
    • (string): The generated vRO JavaScript code

parseCurlCommand(curlCommand)

Parses a curl command and extracts its components.

  • Parameters
    • curlCommand (string): The curl command to parse
  • Returns
    • (Object): An object containing the parsed components (url, method, headers, data)

generateVROCode(parsedCurl, originalCurlCommand)

Generates vRO JavaScript code from parsed curl command components.

  • Parameters
    • parsedCurl (Object): The parsed curl command components
      • url (string): The URL from the curl command
      • method (string): The HTTP method (GET, POST, etc.)
      • headers (Object): The HTTP headers as key-value pairs
      • data (string|null): The request body data (if any)
    • originalCurlCommand (string): The original curl command for reference
  • Returns
    • (string): The generated vRO JavaScript code

Supported Curl Features

  • HTTP methods: GET, POST, PUT, DELETE, PATCH, etc.
  • Request headers with -H or --header
  • Request body data with -d, --data, --data-raw, --data-binary
  • URL specification with or without quotes
  • Basic authentication
  • Form data

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Mayank Goyal
Website: cloudblogger.co.in
Email: [email protected]

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development

To set up the development environment:

# Clone the repository
git clone https://github.com/yourusername/curl2vro.git

# Install dependencies
cd curl2vro
npm install

# Run tests
npm test