fetch-to-curl is a JavaScript/TypeScript utility library that generates `curl` commands from standard Web Fetch API inputs, including URLs, `Request` objects, and `RequestInit` options. Currently at version 0.6.0, it aims for simplicity and minimalism with zero external dependencies. Unlike libraries that patch the global `fetch` object, fetch-to-curl operates as a standalone wrapper, ensuring no side effects on your application's actual network requests. Releases are made periodically to address bug fixes and add minor enhancements, as seen with recent updates supporting URL objects and improving escaping. It is differentiated by its lightweight nature and its direct translation approach, making it ideal for debugging HTTP requests in development environments without modifying the runtime behavior of the application.
npm install fetch-to-curlVerified import paths — ran on the pinned version, not inferred.
Demonstrates converting `fetch` parameters (URL, options, `Request` object, `URL` object) into a cURL command string for debugging.
Upgrade to `fetch-to-curl@0.5.1` or newer to ensure correct escaping of URLs and request bodies.
Update to `fetch-to-curl@0.6.0` or later for improved handling of header values and support for `URL` objects.
For optimal TypeScript compatibility and type safety, ensure you are using `fetch-to-curl@0.5.2` or a newer version.
Ensure you are using named import syntax: `import { fetchToCurl } from 'fetch-to-curl';` for ESM, or `const { fetchToCurl } = require('fetch-to-curl');` for CommonJS. Do not use `import fetchToCurl from 'fetch-to-curl';` as it is not a default export.Change your import statement to use ESM syntax: `import { fetchToCurl } from 'fetch-to-curl';`. If you must use CommonJS, ensure your file is treated as CJS (e.g., `.js` extension without `"type": "module"`).Upgrade `fetch-to-curl` to the latest version (`0.6.0` or newer) to benefit from fixes related to single quote escaping, URL object support, and robust handling of `null`/`undefined` headers. Always test the generated curl command after an upgrade.
No dependency data recorded yet.