Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
Parse curl commands, returning an object representing the request.
JavaScript
Branch: master
Clone or download
Cannot retrieve the latest commit at this time.
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Apr 15, 2016
History.md Release v0.2.6 Nov 17, 2017
Readme.md Update Readme.md Apr 18, 2016
ci.yml
example.js Initial commit Apr 15, 2016
index.js fix fields which contain ":". Closes #10 Nov 17, 2017
package.json Adds repo link to package.json May 18, 2018
test.js fix fields which contain ":". Closes #10 Nov 17, 2017

Readme.md

parse-curl.js

Parse curl commands, returning an object representing the request.

Example

Input:

curl 'http://google.com/' \
  -H 'Accept-Encoding: gzip, deflate, sdch' \
  -H 'Accept-Language: en-US,en;q=0.8,da;q=0.6' \
  -H 'Upgrade-Insecure-Requests: 1' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36' \
  -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' \
  -H 'Connection: keep-alive' \
  --compressed

Output:

{
  "method": "GET",
  "header": {
    "Accept-Encoding": "gzip, deflate, sdch",
    "Accept-Language": "en-US,en;q=0.8,da;q=0.6",
    "Upgrade-Insecure-Requests": "1",
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
    "Connection": "keep-alive"
  },
  "url": "http://google.com/"
}

Badges


tjholowaychuk.com  ·  GitHub @tj  ·  Twitter @tjholowaychuk

You can’t perform that action at this time.