Convert between cURL commands and JavaScript fetch requests seamlessly
The cURL ⇄ Fetch Converter is a bidirectional tool that converts between cURL commands and JavaScript fetch API requests. Perfect for developers who need to quickly switch between command-line testing and browser-based code, or vice versa.


All standard HTTP methods are supported:
Automatically converts all custom headers between formats:
cURL Format:
-H 'Content-Type: application/json'
-H 'Authorization: Bearer token123'
-H 'X-Custom-Header: value'Fetch Format:
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer token123',
'X-Custom-Header': 'value'
}Converts JSON payloads between cURL and fetch formats:
cURL Format:
-d '{"name":"John","age":30}'Fetch Format:
body: JSON.stringify({
name: 'John',
age: 30
})Handles multipart form data including file uploads:
cURL Format:
-F 'file=@photo.jpg'
-F 'name=John'
-F 'email=john@example.com'Fetch Format:
const formData = new FormData();
formData.append('file', file);
formData.append('name', 'John');
formData.append('email', 'john@example.com');
body: formDatacURL:
curl -X GET 'https://api.example.com/users' \
-H 'Authorization: Bearer your-token-here'Fetch:
fetch('https://api.example.com/users', {
method: 'GET',
headers: {
'Authorization': 'Bearer your-token-here'
}
})cURL:
curl -X POST 'https://api.example.com/users' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer your-token' \
-d '{"name":"John Doe","email":"john@example.com","age":30}'Fetch:
fetch('https://api.example.com/users', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your-token'
},
body: JSON.stringify({
name: 'John Doe',
email: 'john@example.com',
age: 30
})
})cURL:
curl -X POST 'https://api.example.com/upload' \
-H 'Authorization: Bearer your-token' \
-F 'file=@document.pdf' \
-F 'title=My Document' \
-F 'description=Important file'Fetch:
const formData = new FormData();
formData.append('file', fileInput.files[0]); // File object
formData.append('title', 'My Document');
formData.append('description', 'Important file');
fetch('https://api.example.com/upload', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-token'
},
body: formData
})
\ for multi-line commandsfileInput.files[0] for file uploadsThe converter generates the fetch request, but you'll need to handle the response. Here's a complete example:
// Generated fetch request
fetch('https://api.example.com/users', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ name: 'John' })
})
// Add response handling
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log('Success:', data);
})
.catch(error => {
console.error('Error:', error);
});
// Or with async/await
try {
const response = await fetch('https://api.example.com/users', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ name: 'John' })
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log('Success:', data);
} catch (error) {
console.error('Error:', error);
}@file.jpg) are converted to placeholder comments in fetch--compressed, --insecure) may not have direct fetch equivalents