Built-in Functions 
Fx provides a set of built-in functions that can be used to process JSON data.
len(x) 
Returns the length of an array, string, or object.
curl https://fx.wtf/example.json | fx lenuniq(x) 
Returns unique values of an array.
curl https://fx.wtf/example.json | fx .tags uniqsort(x) 
Sorts an array.
curl https://fx.wtf/example.json | fx .tags sortsortBy(fn)(x) 
Sorts an array by the function fn.
echo '[1,2,3,4,5]' | fx 'sortBy(x => x % 2 > 0)'sortBy is curried; it returns a function that can be called.
map(fn)(x) 
Maps an array or an object using the function fn.
curl https://fx.wtf/example.json | fx .issues 'map(x => x.title)'map is curried; it returns a function that can be called.
The second argument to fn is the index or the key of the current item.
walk(fn)(x) 
Walks an array or an object using the function fn.
curl https://fx.wtf/example.json | fx 'walk(x => typeof x === "string" ? x.toUpperCase() : x)'Same as map but works recursively. The second argument to fn is the index or the key of the current item.
filter(fn)(x) 
Filters an array or an object using the function fn.
curl https://fx.wtf/example.json | fx .issues 'filter(x => x.state === "open")'groupBy(fn)(x) 
Groups an array by the function fn.
curl https://fx.wtf/example.json | fx .issues 'groupBy(x => x.state)'groupBy is curried; it returns a function that can be used to group an array.
chunk(size)(x) 
Chunks an array into smaller arrays of a given size.
echo '[1,2,3,4,5]' | fx 'chunk(2)'chunk is curried; it returns a function that can be used to chunk an array.
flatten(x) 
Flattens an array.
echo '[[1,2],[3,4],[5]]' | fx flattenreverse(x) 
Reverses an array.
echo '[1,2,3,4,5]' | fx reversekeys(x) 
Returns an array of keys of an object.
echo '{"a": 1, "b": 2}' | fx keysvalues(x) 
Returns an array of values of an object.
echo '{"a": 1, "b": 2}' | fx valueslist(x) 
Prints an array as a list. This is useful for combining output with other commands.
echo '[1, 2, 3]' | fx list | xargs -I{} echo "The number is {}"save(x) 
Edits the input data in place.
fx example.json 'x.name = x.name.toUpperCase(), x' saveThe edited data will be saved to the same example.json file.
toBase64(x) 
Encodes a string to base64.
curl https://fx.wtf/example.json | fx .text toBase64fromBase64(x) 
Decodes a base64 string.
echo '"SGVsbG8sIFdvcmxkIQ=="' | fx fromBase64YAML.stringify(x) 
Converts a JSON object to YAML.
curl https://fx.wtf/example.json | fx '.users[]' YAML.stringifyYAML.parse(x) 
Converts a YAML string to JSON.
INFO
You can use the --yaml flag to parse YAML:
cat example.yaml | fx --yamlFx will also automatically detect YAML files with the .ya?ml extension.
fx example.yaml