Convert Figma logo to code with AI

jqlang logojq

Command-line JSON processor

30,059
1,555
30,059
453

Top Related Projects

30,058

Command-line JSON processor

11,663

yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor

13,728

Make JSON greppable!

18,903

Terminal JSON viewer & processor

7,019

Select, put and delete data from JSON, TOML, YAML, XML and CSV files with a single tool. Supports conversion between formats and can be used as a Go package.

1,962

JSON Stream Editor (command line utility)

Quick Overview

jq is a lightweight command-line JSON processor. It's like sed for JSON data – you can use it to slice, filter, map, and transform structured data with ease. jq is written in portable C and has zero runtime dependencies, making it highly versatile and efficient.

Pros

  • Powerful and flexible JSON manipulation capabilities
  • Fast performance and low resource usage
  • Extensive documentation and large user community
  • Cross-platform support (Linux, macOS, Windows)

Cons

  • Steep learning curve for complex operations
  • Syntax can be cryptic for beginners
  • Limited support for non-JSON data formats
  • Some advanced features require careful handling to avoid errors

Code Examples

  1. Basic filtering:
echo '{"name": "John", "age": 30, "city": "New York"}' | jq '.name'
# Output: "John"
  1. Array manipulation:
echo '[1,2,3,4,5]' | jq 'map(. * 2)'
# Output: [2,4,6,8,10]
  1. Complex data transformation:
echo '{"users": [{"name": "Alice", "age": 25}, {"name": "Bob", "age": 30}]}' | jq '.users | map({name: .name, is_adult: (.age >= 18)})'
# Output: [
#   {
#     "name": "Alice",
#     "is_adult": true
#   },
#   {
#     "name": "Bob",
#     "is_adult": true
#   }
# ]

Getting Started

  1. Install jq:

    • On macOS: brew install jq
    • On Ubuntu/Debian: sudo apt-get install jq
    • On Windows: Download from the official GitHub releases page
  2. Basic usage:

    echo '{"key": "value"}' | jq '.'
    
  3. Read from a file:

    jq '.' input.json
    
  4. Save output to a file:

    jq '.' input.json > output.json
    

For more advanced usage, refer to the official jq manual: https://stedolan.github.io/jq/manual/

Competitor Comparisons

30,058

Command-line JSON processor

Pros of jq

  • Widely adopted and well-established JSON processing tool
  • Extensive documentation and community support
  • Powerful and flexible query language for JSON manipulation

Cons of jq

  • Limited to JSON processing only
  • Steeper learning curve for complex operations
  • Slower performance for large datasets compared to some alternatives

Code Comparison

jq:

.[] | select(.name == "Alice") | .age += 1

Both repositories appear to be the same project (jq), so there isn't a meaningful code comparison to make between them. The jqlang organization on GitHub hosts the official jq repository.

Summary

jq is a lightweight command-line JSON processor that has become a standard tool for working with JSON data. It offers a rich set of features for filtering, transforming, and manipulating JSON structures. While it excels in JSON processing, it may not be the best choice for other data formats or extremely large datasets. The learning curve can be steep for advanced operations, but the extensive documentation and community support make it easier to master over time.

11,663

yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor

Pros of yq

  • Supports multiple data formats (YAML, JSON, XML, properties)
  • Easier syntax for basic operations
  • Better documentation and examples

Cons of yq

  • Less powerful for complex transformations
  • Slower performance for large datasets
  • Smaller community and ecosystem

Code Comparison

yq:

yq e '.users[] | select(.age > 30)' input.yaml

jq:

jq '.users[] | select(.age > 30)' input.json

Summary

yq is a versatile tool for working with multiple data formats, offering an easier syntax for basic operations and better documentation. It's particularly useful for YAML processing. However, jq excels in complex JSON transformations and has better performance for large datasets.

yq is ideal for users who frequently work with YAML or need to switch between different data formats. jq is better suited for advanced JSON processing and handling large-scale data operations.

The choice between yq and jq depends on the specific use case, data format requirements, and the complexity of the transformations needed. Both tools have their strengths and can be valuable additions to a developer's toolkit.

13,728

Make JSON greppable!

Pros of gron

  • Simpler syntax and easier to learn for beginners
  • Outputs flattened JSON structure, making it easier to grep and process with other Unix tools
  • Faster for simple transformations and quick inspections

Cons of gron

  • Less powerful for complex JSON manipulations
  • Limited functionality compared to jq's extensive feature set
  • Not as widely adopted or supported in the community

Code Comparison

gron example:

echo '{"name": "Tom", "age": 30}' | gron
json = {};
json.name = "Tom";
json.age = 30;

jq example:

echo '{"name": "Tom", "age": 30}' | jq '.'
{
  "name": "Tom",
  "age": 30
}

gron focuses on flattening JSON into assignable JavaScript-like statements, while jq provides a more comprehensive JSON processing language with advanced filtering and transformation capabilities. gron is ideal for quick inspections and simple grep operations, whereas jq excels in complex JSON manipulations and data extraction tasks.

18,903

Terminal JSON viewer & processor

Pros of fx

  • Interactive terminal interface for exploring JSON data
  • Supports JavaScript expressions for data manipulation
  • Can handle streaming data and large files efficiently

Cons of fx

  • Less mature and widely adopted compared to jq
  • Limited built-in functions compared to jq's extensive library
  • May require more setup and dependencies for some users

Code Comparison

fx:

fx '_.groupBy(x => x.category)'

jq:

group_by(.category)

Both tools allow for data manipulation, but fx uses JavaScript syntax while jq has its own domain-specific language. fx's approach may be more familiar to developers with JavaScript experience, while jq's syntax is more concise for certain operations.

fx is better suited for interactive exploration and working with large datasets, while jq excels in scripting and command-line usage. jq has a more extensive set of built-in functions and is more widely adopted in shell scripts and data processing pipelines.

The choice between fx and jq depends on the specific use case, personal preference, and the existing ecosystem in which the tool will be used. fx may be preferred for its interactive features and JavaScript integration, while jq is often chosen for its maturity, performance, and extensive documentation.

7,019

Select, put and delete data from JSON, TOML, YAML, XML and CSV files with a single tool. Supports conversion between formats and can be used as a Go package.

Pros of dasel

  • Supports multiple data formats (JSON, YAML, TOML, XML) out of the box
  • Allows for data manipulation and transformation across different formats
  • Provides a simpler syntax for basic operations compared to jq

Cons of dasel

  • Less powerful for complex JSON manipulations compared to jq
  • Smaller community and ecosystem than jq
  • May be slower for large JSON datasets

Code Comparison

dasel:

dasel select -f input.json '.users.name'
dasel put string -f input.json '.users.name' 'John'

jq:

jq '.users.name' input.json
jq '.users.name = "John"' input.json

Both tools allow for selecting and modifying JSON data, but dasel's syntax is more straightforward for basic operations. However, jq offers more advanced features for complex JSON manipulations.

dasel is versatile across multiple data formats, making it suitable for projects dealing with various data types. jq, on the other hand, excels in JSON-specific operations and has a larger community, which can be beneficial for troubleshooting and finding advanced usage examples.

Choose dasel for multi-format data handling and simpler syntax, or jq for powerful JSON-specific operations and a more established ecosystem.

1,962

JSON Stream Editor (command line utility)

Pros of jj

  • Written in Go, potentially offering better performance and easier deployment
  • Simpler syntax for basic operations, making it more approachable for beginners
  • Lightweight and focused on core JSON manipulation tasks

Cons of jj

  • Less feature-rich compared to jq's extensive functionality
  • Smaller community and ecosystem, with fewer resources and extensions available
  • May not handle complex transformations as elegantly as jq

Code Comparison

jq:

jq '.items[] | {id: .id, name: .name, price: .price}'

jj:

jj '..items.#.{id,name,price}'

Both examples extract id, name, and price from items in a JSON object. jj's syntax is more concise, while jq offers more flexibility for complex operations.

jj is a good choice for simpler JSON processing tasks and users who prefer Go-based tools. However, jq remains the more powerful and versatile option for advanced JSON manipulation, with a larger community and more extensive documentation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

jq

jq is a lightweight and flexible command-line JSON processor akin to sed,awk,grep, and friends for JSON data. It's written in portable C and has zero runtime dependencies, allowing you to easily slice, filter, map, and transform structured data.

Documentation

Installation

Prebuilt Binaries

Download the latest releases from the GitHub release page.

Docker Image

Pull the jq image to start quickly with Docker.

Run with Docker

Example: Extracting the version from a package.json file
docker run --rm -i ghcr.io/jqlang/jq:latest < package.json '.version'
Example: Extracting the version from a package.json file with a mounted volume
docker run --rm -i -v "$PWD:$PWD" -w "$PWD" ghcr.io/jqlang/jq:latest '.version' package.json

Building from source

Dependencies

  • libtool
  • make
  • automake
  • autoconf

Instructions

git submodule update --init    # if building from git to get oniguruma
autoreconf -i                  # if building from git
./configure --with-oniguruma=builtin
make clean                     # if upgrading from a version previously built from source
make -j8
make check
sudo make install

Build a statically linked version:

make LDFLAGS=-all-static

If you're not using the latest git version but instead building a released tarball (available on the release page), skip the autoreconf step, and flex or bison won't be needed.

Cross-Compilation

For details on cross-compilation, check out the GitHub Actions file and the cross-compilation wiki page.

Community & Support

License

jq is released under the MIT License. jq's documentation is licensed under the Creative Commons CC BY 3.0. jq uses parts of the open source C library "decNumber", which is distributed under ICU License