Top Related Projects
Command-line JSON processor
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.
yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor
Make JSON greppable!
json incremental digger
JSON Stream Editor (command line utility)
Quick Overview
fx is a command-line JSON processing tool that allows users to interactively explore and manipulate JSON data. It provides a simple yet powerful interface for querying, filtering, and transforming JSON structures, making it an invaluable tool for developers and system administrators working with JSON data.
Pros
- Interactive mode for exploring JSON data in real-time
- Supports both JavaScript and jq-like syntax for querying
- Can handle large JSON files efficiently
- Extensible with custom functions and modules
Cons
- Learning curve for advanced features and syntax
- Limited built-in formatting options compared to some alternatives
- Requires Node.js runtime, which may not be available in all environments
- Documentation could be more comprehensive for complex use cases
Code Examples
- Basic JSON filtering:
echo '{"name": "John", "age": 30, "city": "New York"}' | fx 'x => x.name'
This example filters the JSON input to return only the "name" field.
- Using array methods:
echo '[1, 2, 3, 4, 5]' | fx 'x => x.filter(n => n % 2 === 0)'
This example filters an array to return only even numbers.
- Combining multiple operations:
echo '{"users": [{"name": "Alice", "age": 25}, {"name": "Bob", "age": 30}]}' | fx 'x => x.users.map(u => u.name).join(", ")'
This example extracts user names from a nested structure and joins them into a comma-separated string.
Getting Started
To get started with fx, follow these steps:
-
Install fx using npm:
npm install -g fx
-
Use fx with a JSON file or piped input:
cat data.json | fx
-
Enter JavaScript expressions to manipulate the data:
.users.filter(u => u.age > 25)
-
Press Ctrl+D to exit the interactive mode and output the result.
For more advanced usage and features, refer to the project's GitHub repository and documentation.
Competitor Comparisons
Command-line JSON processor
Pros of jq
- More mature and widely adopted project with extensive documentation
- Supports a broader range of JSON manipulation operations
- Faster performance for large JSON datasets
Cons of jq
- Steeper learning curve due to its unique syntax
- Less interactive and visual compared to fx's terminal interface
- Limited to JSON processing, while fx can handle other data formats
Code Comparison
jq example:
echo '{"name": "John", "age": 30}' | jq '.name'
fx example:
echo '{"name": "John", "age": 30}' | fx .name
Summary
jq is a powerful and established JSON processor with a wide range of capabilities, but it requires learning its specific syntax. fx offers a more user-friendly, interactive approach with support for multiple data formats, making it easier for beginners to manipulate JSON data. While jq excels in performance and advanced JSON operations, fx provides a more accessible and versatile tool for quick data exploration and manipulation in the terminal.
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, CSV)
- Can be used as a command-line tool or as a Go package
- Allows for data modification and transformation
Cons of dasel
- Less interactive than fx for exploring data
- May have a steeper learning curve for complex operations
- Limited to specific data formats, while fx can work with any JavaScript object
Code comparison
dasel:
dasel -f data.json '.users.[].name'
fx:
cat data.json | fx '.users[].name'
Summary
dasel is a versatile tool for querying and modifying various data formats, offering both command-line and programmatic usage. It excels in handling multiple data types and performing data transformations. However, it may be less intuitive for quick data exploration compared to fx.
fx, on the other hand, provides a more interactive experience for exploring JSON data and can work with any JavaScript object. It's generally easier to use for simple queries but may be limited in terms of data modification capabilities.
The choice between dasel and fx depends on the specific use case, with dasel being more suitable for complex data operations across multiple formats, while fx is better for quick JSON exploration and manipulation.
yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor
Pros of yq
- Specialized for YAML processing, offering robust YAML-specific features
- Supports multiple input formats (JSON, XML, properties) and can convert between them
- Lightweight and fast, with minimal dependencies
Cons of yq
- Limited to command-line usage, lacking interactive features
- Less flexible for general-purpose data manipulation compared to fx
- Steeper learning curve for complex operations
Code Comparison
fx:
echo '{"foo": "bar"}' | fx 'x => x.foo.toUpperCase()'
yq:
echo '{"foo": "bar"}' | yq '.foo | upcase'
Key Differences
- fx is a general-purpose JSON processing tool with JavaScript syntax
- yq focuses on YAML processing with jq-like syntax
- fx offers an interactive mode for exploring data structures
- yq excels at YAML-specific operations and format conversions
Both tools are valuable for different use cases. fx is more versatile for general data manipulation, while yq specializes in YAML processing and format conversions. The choice between them depends on the specific requirements of your project and personal preferences.
Make JSON greppable!
Pros of gron
- Simpler and more focused on flattening JSON into greppable format
- Faster processing for large JSON files
- Easier to use in shell pipelines and scripts
Cons of gron
- Less interactive and feature-rich compared to fx
- Limited to JSON flattening and doesn't offer advanced querying capabilities
- No built-in pretty-printing or colorization options
Code Comparison
gron:
gron example.json
json = {};
json.name = "John Doe";
json.age = 30;
json.hobbies = [];
json.hobbies[0] = "reading";
fx:
echo '{"name":"John Doe","age":30,"hobbies":["reading"]}' | fx
{
name: 'John Doe',
age: 30,
hobbies: [
'reading'
]
}
Summary
gron excels at flattening JSON for easy grepping and shell scripting, while fx offers a more interactive and feature-rich JSON exploration experience. gron is better suited for quick command-line operations and integration into existing shell workflows, whereas fx provides a more comprehensive toolkit for JSON manipulation and querying. The choice between the two depends on the specific use case and personal preference for simplicity versus advanced features.
json incremental digger
Pros of jid
- Written in Go, which may offer better performance for large JSON files
- Supports incremental JSON digger functionality for interactive exploration
- Provides a terminal-based UI for easier navigation of complex JSON structures
Cons of jid
- Limited to JSON processing only, while fx supports multiple data formats
- Less extensive scripting capabilities compared to fx's JavaScript support
- Lacks advanced features like custom output formatting and data transformation
Code Comparison
jid example:
echo '{"foo": 123}' | jid
fx example:
echo '{"foo": 123}' | fx .foo
Summary
jid is a lightweight, Go-based tool focused on interactive JSON exploration with a terminal UI. It excels in quick JSON navigation but has limited functionality beyond that. fx, on the other hand, is a more versatile JavaScript-based tool that supports multiple data formats and offers advanced scripting capabilities for complex data manipulation and transformation tasks.
Both tools have their strengths, with jid being more suitable for quick JSON inspection and fx being better for comprehensive data processing workflows. The choice between them depends on the specific use case and the level of functionality required.
JSON Stream Editor (command line utility)
Pros of jj
- Written in Go, potentially offering better performance for large JSON files
- Supports in-place JSON editing, allowing modifications to the original file
- Provides a simpler command-line interface for basic JSON operations
Cons of jj
- Limited interactive features compared to fx's terminal UI
- Fewer advanced querying and manipulation capabilities
- Less extensive documentation and community support
Code Comparison
fx:
echo '{"key": "value"}' | fx .key
jj:
echo '{"key": "value"}' | jj .key
Both tools use similar syntax for basic JSON querying, but fx offers more advanced features for complex operations and data exploration.
Summary
jj is a lightweight, Go-based JSON processor focused on simplicity and performance. It excels in basic JSON operations and in-place editing. fx, on the other hand, provides a more feature-rich environment with an interactive terminal UI, making it better suited for complex data exploration and manipulation tasks. The choice between the two depends on the specific use case and the level of JSON processing required.
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
f(x)
Special thanks to:
Warp is a modern, Rust-based terminal with AI built in so you and your team can build great software, faster.
Visit warp.dev to learn more.
Install
brew install fx
Documentation
See full documentation at fx.wtf.
License
Top Related Projects
Command-line JSON processor
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.
yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor
Make JSON greppable!
json incremental digger
JSON Stream Editor (command line utility)
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