curl to Code Converter

Turn a curl command into JavaScript, Python, Go or PHP, with the request it builds and every flag left out.

Code
const response = await fetch('https://api.quackyard.com/v1/ducks', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
  },
  body: JSON.stringify({ name: 'Duck Pond', tags: ['a', 'b', 'c'] }),
});

const data = await response.json();
console.log(data);

The request it builds

MethodPOST
URLhttps://api.quackyard.com/v1/ducks
HeaderContent-Type: application/json
HeaderAccept: application/json
Body{"name":"Duck Pond","tags":["a","b","c"]}

Left out of the code

  • --compressedfetch asks for a compressed response and unpacks it on its own

More in the yard