Registry / devops / curl-to-fetch

curl-to-fetch

JSON →
library1.2.1jsnpmunverified

Library to parse curl command strings and generate equivalent fetch() API code. Stable version 1.2.1. Low maintenance, limited updates. Differentiator: lightweight alternative to curlconverter with support for common curl flags via parse-curl.js. Outputs fetch() with .then(console.log, console.error) chained. Limited to GET requests and cookie headers; does not support full HTTP method/payload translation.

npm install curl-to-fetch
INSTALL
IMPORT
SIG · CURL-TO-FETCH
C
curl-to-fetch
devopsjavascriptv1.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const parse = require('curl-to-fetch');
import parse from 'curl-to-fetch';
Package uses CommonJS, not ESM. No named exports.
parse
const parse = require('curl-to-fetch');
const { parse } = require('curl-to-fetch');
Export is a single function, not a named export.

Parses a curl command and logs the equivalent fetch() call.

const parse = require('curl-to-fetch'); const curlCmd = "curl --cookie 'species=sloth;type=galactic' slothy https://api.sloths.com"; const fetchCode = parse(curlCmd); console.log(fetchCode); // Output: // fetch( // 'https://api.sloths.com', // {headers:{"Set-Cookie":"species=sloth;type=galactic"}, // method:'GET'} // ) // .then(console.log, console.error)
Debug
Known issues
gotchaOutput always uses GET method; POST, PUT etc. not supported.
fix
Manually modify method in fetch call if needed.
affects: <=1.2.1
gotchaCookies are output as Set-Cookie header, not as credentials option.
fix
Use credentials: 'include' or set manual cookie header.
affects: <=1.2.1
gotchaThe generated fetch code includes .then(console.log, console.error) which may not be desired.
fix
Remove or modify the .then chain after code generation.
affects: <=1.2.1
gotchaOnly parses first URL from input; multiple URLs ignored.
fix
Split input and parse each curl command separately.
affects: <=1.2.1
Errors
Common errors & fixes
Error: Cannot find module 'parse-curl'
Missing dependency parse-curl
fix
npm install parse-curl
TypeError: parse is not a function
Incorrect import (e.g., destructured named export)
fix
Use const parse = require('curl-to-fetch');
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
parse-curlrequiredParses curl flags and arguments
Agent activity
7 hits · last 30 days
node
6
Bingbot
1
Resources
curl-to-fetch — npm install curl-to-fetch · libregistry