Install JQ on Windows

The Windows binary file for jq can be downloaded from
https://stedolan.github.io/jq/download/

At the time of writing, the latest version is
https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64.exe

If you want the jq command to be available from everywhere within windows there are 3 steps to be followed:

  • Create the directory C:\Program Files\JQ
  • Download the file
  • Rename the file jq-win64.exe to jq.exe
  • Set the Path

    Here is a PowerShell that can do all the above steps (useful if you need to install it on multiple computers):
$jqFolderPath = "C:\Program Files\JQ"
$jqExePath = "$jqFolderPath\jq.exe"
$jqDownloadUrl = "https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64.exe"

# Step 1: Create the folder if it doesn't exist
if (-not (Test-Path $jqFolderPath -PathType Container)) {
    New-Item -Path $jqFolderPath -ItemType Directory | Out-Null
}

# Step 2: Download jq-win64.exe
Invoke-WebRequest -Uri $jqDownloadUrl -OutFile $jqExePath

# Step 3: Rename jq-win64.exe to jq.exe
Rename-Item -Path $jqExePath -NewName "jq.exe"

# Step 4: Set the path
$existingPath = [Environment]::GetEnvironmentVariable("Path", "User")
$newPath = "$existingPath;$jqFolderPath"
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")

Save the above code in a file named install_jq.ps1
Open the PowerShell as Administrator, and allow the execution of remote scripts:

Set-ExecutionPolicy RemoteSigned

Once you allowed custom PowerShell scripts to run, then you can run the installer.

.\install_jq.ps1

Reboot the computer. After reboot the Path is active and you can use jq as ususal. You will have an output like this:

C:\>jq
jq - commandline JSON processor [version 1.6]

Usage:  jq [options] <jq filter> [file...]
        jq [options] --args <jq filter> [strings...]
        jq [options] --jsonargs <jq filter> [JSON_TEXTS...]

jq is a tool for processing JSON inputs, applying the given filter to
its JSON text inputs and producing the filter's results as JSON on
standard output.

The simplest filter is ., which copies jq's input to its output
unmodified (except for formatting, but note that IEEE754 is used
for number representation internally, with all that that implies).

For more advanced filters see the jq(1) manpage ("man jq")
and/or https://stedolan.github.io/jq

Example:

        $ echo '{"foo": 0}' | jq .
        {
                "foo": 0
        }

For a listing of options, use jq --help.