Different Ways to Handle JSON in a Linux Shell

Tate Galbraith
The Startup
Published in
5 min readFeb 25, 2021

--

Photo by Ferenc Almasi on Unsplash

Who doesn’t love a good JSON blob? That’s the way most of our data comes these days. Whether you’re interacting with an API or gathering some data from a database, you’re probably getting back JSON. Most popular programming languages have built-in ways to manipulate and parse JSON into different objects and formats. However, if you’re working with data at the shell level in Bash, things aren’t always so simple.

By default shells like Bash do not have a standard JSON parser included. You would either have to drop into a programming language interpreter or install a small dedicated utility. If you’re trying to stay within the confines of the shell, then adding a program is arguably the most straightforward option. This way you don’t have to deal with setting up a different language (and its dependencies) or handle moving back and forth between the two.

Most dedicated JSON manipulation programs are also exceptionally fast, have a small footprint and don’t need additional dependencies whatsoever.

In this article, we’ll explore some popular applications that add this crucial functionality to your shell. This will let you handle JSON data in shell scripts and make on-the-fly manipulations without having to switch to a more robust programming language. Let’s take a look.

jq

--

--

Tate Galbraith
The Startup

Software Engineer @mixhalo & die-hard Rubyist. Amateur Radio operator with a love for old technology. Tweet at me: https://twitter.com/@Tate_Galbraith