A powerful TypeScript tool to convert cURL commands to structured JSON format with Puppeteer browser automation and dynamic cookie parsing.
- ✅ Input Validation: validation with detailed error messages and type safety
- 🧪 Testing Suite: Jest test coverage with organized test structure and validation tests
- 🔍 Smart Parsing: commands and extract headers, cookies, and request parameters with comprehensive validation
- 🤖 Puppeteer Integration: to Puppeteer-compatible format for browser automation and session management
- 🔄 Dynamic Cookie Extraction: HTTP requests to get live cookies from websites with automatic fallback
- 📊 Multiple Formats: to basic request object, detailed cookies, fetch options, and Puppeteer format
- 📝 Full TypeScript Support: definitions and JSDoc documentation for all functions
- 🔧 Modular Architecture: parser, converter, and CLI components for easy maintenance
- 🚀 Browser Automation: Puppeteer scripts for authenticated web scraping
npm installConvert a cURL file to JSON:
npx ts-node src/cli.ts --input request.txt --output converted.jsonConvert from stdin:
cat request.txt | npx ts-node src/cli.ts --stdinimport { CurlToJsonConverter } from './src/converter'
const converter = new CurlToJsonConverter()
// Basic conversion
const result = converter.convert(curlCommand)
// Detailed cookies (async)
const detailedCookies = await converter.convertToDetailedCookies(curlCommand)
// Puppeteer-compatible cookies (async)
const puppeteerCookies = await converter.convertToPuppeteerCookies(curlCommand)
// Complete conversion with all formats
const allResults = await converter.convertAll(curlCommand)import puppeteer from 'puppeteer'
import { CurlToJsonConverter } from './src/converter'
const converter = new CurlToJsonConverter()
const puppeteerCookies = await converter.convertToPuppeteerCookies(curlCommand)
const browser = await puppeteer.launch({ headless: false })
await browser.setCookie(...puppeteerCookies)
const page = await browser.newPage()
await page.goto('https://example.com'){
"url": "https://example.com/api",
"method": "GET",
"headers": { "authorization": "Bearer token" },
"cookies": { "session": "abc123" },
"compressed": true
}[
{
"name": "sessionKey",
"value": "sk-ant-sid01-...",
"domain": "claude.ai",
"path": "/",
"expires": 1756488873,
"httpOnly": true,
"secure": true,
"sameSite": "Lax"
}
][
{
"name": "sessionKey",
"value": "sk-ant-sid01-...",
"domain": "claude.ai",
"path": "/",
"expires": 1756488873,
"httpOnly": true,
"secure": true,
"sameSite": "Lax",
"sameParty": false,
"sourceScheme": "NonSecure"
}
]Run the complete test suite:
npm testRun specific tests:
npm run test:watch # Watch mode
npm run test:coverage # Coverage report
npm run validation-test # Validation tests
npm run puppeteer-format-test # Puppeteer format testsnpm run convert: Run the converternpm run test: Run all testsnpm run test:watch: Run tests in watch modenpm run test:coverage: Generate coverage reportnpm run validation-test: Test input validationnpm run puppeteer-format-test: Test Puppeteer cookie formatnpm run build: Compile to JavaScriptnpm start: Run compiled version
- cURL Command Validation: Ensures proper cURL syntax and URL format
- Input Validation: Validates string inputs and file paths
- Error Handling: Comprehensive error messages with context
- Type Safety: Full TypeScript type checking
- Web Scraping: Convert browser requests to automated scripts
- API Testing: Transform cURL commands to test suites
- Session Management: Extract and reuse authentication cookies
- Browser Automation: Inject cookies into Puppeteer for authenticated sessions
- Request Analysis: Parse and analyze complex HTTP requests
src/
├── parser.ts # cURL command parsing
├── converter.ts # Format conversion logic
├── cli.ts # Command-line interface
├── types.ts # TypeScript definitions
└── index.ts # Main exports
tests/
├── parser.test.ts # Parser unit tests
├── converter.test.ts # Converter unit tests
├── validation.test.ts # Validation tests
├── puppeteer.test.ts # Puppeteer integration tests
└── simple.test.ts # Basic test setup
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.