Top Related Projects
Command-line JSON processor
Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
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.
Make JSON greppable!
Pure Go implementation of jq
Quick Overview
yj is a command-line tool that converts between YAML, TOML, JSON, and HCL formats. It provides a simple and efficient way to transform data between these popular configuration and data serialization formats, making it useful for developers and system administrators working with various configuration files and data interchange scenarios.
Pros
- Easy to use with a straightforward command-line interface
- Supports bidirectional conversion between YAML, TOML, JSON, and HCL
- Lightweight and fast, with no external dependencies
- Can handle complex nested structures and data types
Cons
- Limited to four specific formats (YAML, TOML, JSON, HCL)
- No support for custom data types or schema validation
- Lacks advanced features like data manipulation or filtering
- May require manual installation on some systems
Code Examples
# Convert YAML to JSON
echo "key: value" | yj -yj
# Output: {"key":"value"}
# Convert JSON to TOML
echo '{"nested": {"key": "value"}}' | yj -jt
# Output:
# [nested]
# key = "value"
# Convert HCL to YAML
echo 'resource "aws_instance" "example" { ami = "ami-123456" }' | yj -hy
# Output:
# resource:
# aws_instance:
# example:
# ami: ami-123456
Getting Started
-
Install yj:
# On macOS using Homebrew brew install yj # On other systems, download the binary from GitHub releases # https://github.com/sclevine/yj/releases
-
Use yj in your command line:
# Convert YAML to JSON cat config.yaml | yj -yj > config.json # Convert JSON to TOML cat data.json | yj -jt > data.toml # Convert HCL to YAML cat terraform.tf | yj -hy > terraform.yaml
Competitor Comparisons
Command-line JSON processor
Pros of jq
- More mature and widely adopted project with extensive documentation
- Supports a rich query language for complex JSON transformations
- Offers a wide range of built-in functions and operators
Cons of jq
- Steeper learning curve due to its complex query language
- Larger binary size and potentially slower for simple operations
Code Comparison
yj example:
yj -yj < input.yaml | jq '.foo.bar'
jq example:
jq '.foo.bar' input.json
Key Differences
- yj focuses on YAML/JSON conversion, while jq specializes in JSON processing
- yj is written in Go, whereas jq is implemented in C
- yj has a simpler syntax for basic operations, but jq offers more advanced features
Use Cases
- Use yj for quick YAML/JSON conversions and simple data manipulations
- Choose jq for complex JSON transformations and when working exclusively with JSON data
Community and Support
- jq has a larger community and more third-party resources available
- yj is actively maintained but has a smaller user base
Performance
- yj may be faster for simple conversions between YAML and JSON
- jq excels in performance for complex JSON operations and large datasets
Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
Pros of yq
- Written in Python, making it more accessible for scripting and integration with Python projects
- Supports both YAML and JSON, with additional features for XML and TOML
- Offers a rich set of operations and filters for data manipulation
Cons of yq
- May have slower performance compared to yj, especially for large files
- Requires Python runtime, which might not be available in all environments
- More complex syntax for some operations due to its extensive feature set
Code comparison
yq example:
echo '{"foo": "bar"}' | yq '.foo'
yj example:
echo '{"foo": "bar"}' | yj -tj | jq '.foo'
Key differences
- yj focuses on format conversion (YAML, JSON, TOML) and is written in Go
- yq provides a more comprehensive toolset for querying and manipulating data
- yj requires separate tools like jq for data manipulation, while yq integrates these features
Use cases
- yj: Lightweight format conversion in shell scripts or CI/CD pipelines
- yq: Complex data manipulation tasks, especially in Python-friendly environments
Both tools have their strengths, and the choice depends on specific project requirements, performance needs, and the preferred programming language ecosystem.
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 more data formats (JSON, YAML, TOML, XML, CSV)
- Offers both reading and writing capabilities
- Provides a more extensive command-line interface with various subcommands
Cons of dasel
- Larger binary size and potentially higher resource usage
- May have a steeper learning curve due to more features and options
Code Comparison
dasel:
dasel -f input.yaml -r yaml -w json '.users[0].name'
yj:
yj -yj < input.yaml | jq '.users[0].name'
Key Differences
- dasel is a more feature-rich tool with support for multiple formats and operations
- yj focuses primarily on conversion between YAML and JSON
- dasel can perform both read and write operations, while yj is mainly for conversion
- yj requires additional tools (like jq) for complex data manipulation, whereas dasel has built-in query capabilities
Use Cases
- Choose dasel for projects requiring manipulation of various data formats and complex operations
- Opt for yj in simpler scenarios where quick YAML-JSON conversion is the primary need
Community and Development
- dasel has more recent updates and a larger community
- yj is more lightweight and focused on its core functionality
Both tools have their merits, and the choice depends on the specific requirements of your project and workflow.
Make JSON greppable!
Pros of gron
- Provides a flattened, greppable JSON output, making it easier to search and filter JSON data
- Supports reverse transformation, allowing users to convert gron output back to JSON
- Lightweight and fast, with minimal dependencies
Cons of gron
- Limited to JSON input and output formats
- Lacks support for other data formats like YAML or TOML
- Does not offer advanced data manipulation features
Code comparison
gron:
echo '{"name": "Tom", "age": 30}' | gron
json = {};
json.name = "Tom";
json.age = 30;
yj:
echo '{"name": "Tom", "age": 30}' | yj -jy
name: Tom
age: 30
Key differences
- gron focuses on flattening JSON for easier grepping and searching
- yj is a more versatile tool for converting between various data formats (JSON, YAML, TOML, HCL)
- gron's output is designed to be easily parsed and manipulated using standard Unix tools
- yj provides a wider range of input and output format options, making it more suitable for complex data transformation tasks
Both tools serve different purposes and can be valuable in different scenarios, depending on the specific requirements of the user's workflow.
Pure Go implementation of jq
Pros of gojq
- More comprehensive JSON processing capabilities, including complex queries and transformations
- Better performance for large JSON datasets
- Actively maintained with regular updates and improvements
Cons of gojq
- Larger binary size and more complex installation process
- Steeper learning curve due to more advanced features
Code Comparison
gojq:
jq := gojq.New()
iter := jq.Run(input, ".foo.bar")
for {
v, ok := iter.Next()
if !ok {
break
}
// Process v
}
yj:
var data interface{}
err := yaml.Unmarshal(input, &data)
if err != nil {
// Handle error
}
jsonData, err := json.Marshal(data)
if err != nil {
// Handle error
}
Summary
gojq is a more powerful and feature-rich JSON processing tool, offering advanced querying capabilities and better performance for large datasets. However, it comes with a larger footprint and may be overkill for simple YAML-to-JSON conversions.
yj, on the other hand, is a lightweight tool specifically designed for YAML/JSON conversions. It's simpler to use and has a smaller binary size, making it ideal for basic conversion tasks. However, it lacks the advanced querying and manipulation features of gojq.
Choose gojq for complex JSON processing needs, and yj for straightforward YAML/JSON conversions in resource-constrained environments.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME

Convert between YAML, TOML, JSON, and HCL.
Preserves map order.
Format versions:
- YAML: v1.2 (gopkg.in/yaml.v3)
- TOML: v1.0.0 (github.com/BurntSushi/toml)
- JSON: RFC 7159 (encoding/json)
- HCL: v1 (github.com/hashicorp/hcl)
$ yj -h
Usage: yj [-][ytjcrneikhv]
Convert between YAML, TOML, JSON, and HCL.
Preserves map order.
-x[x] Convert using stdin. Valid options:
-yj, -y = YAML to JSON (default)
-yy = YAML to YAML
-yt = YAML to TOML
-yc = YAML to HCL
-tj, -t = TOML to JSON
-ty = TOML to YAML
-tt = TOML to TOML
-tc = TOML to HCL
-jj = JSON to JSON
-jy, -r = JSON to YAML
-jt = JSON to TOML
-jc = JSON to HCL
-cy = HCL to YAML
-ct = HCL to TOML
-cj, -c = HCL to JSON
-cc = HCL to HCL
-n Do not covert inf, -inf, and NaN to/from strings (YAML or TOML only)
-e Escape HTML (JSON out only)
-i Indent output (JSON or TOML out only)
-k Attempt to parse keys as objects or numeric types (YAML out only)
-h Show this help message
-v Show version
Installation
Homebrew
The yj
CLI is available via Homebrew:
brew install yj
Manual
Binaries for macOS, Linux, and Windows are attached to each release.
Docker
yj
is also available as a Docker image.
Go Package
Packages contained in this repo may also be used to convert all supported data formats to a normalized tree of ordered Go objects.
See godoc for details.
NOTE: The current Go API should not be considered stable.
Top Related Projects
Command-line JSON processor
Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
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.
Make JSON greppable!
Pure Go implementation of jq
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot