<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: siyadhkc</title>
    <description>The latest articles on DEV Community by siyadhkc (@siyadhkc).</description>
    <link>https://dev.to/siyadhkc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3868439%2F5c0b2e2e-0a7c-406f-9d99-1d810624972c.png</url>
      <title>DEV Community: siyadhkc</title>
      <link>https://dev.to/siyadhkc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/siyadhkc"/>
    <language>en</language>
    <item>
      <title>I built a modern alternative to gron using Bun and TypeScript</title>
      <dc:creator>siyadhkc</dc:creator>
      <pubDate>Sun, 12 Apr 2026 17:16:36 +0000</pubDate>
      <link>https://dev.to/siyadhkc/i-built-a-modern-alternative-to-gron-using-bun-and-typescript-3358</link>
      <guid>https://dev.to/siyadhkc/i-built-a-modern-alternative-to-gron-using-bun-and-typescript-3358</guid>
      <description>&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Working with JSON in the terminal is painful. &lt;code&gt;jq&lt;/code&gt; is powerful &lt;br&gt;
but requires learning a whole query language. &lt;code&gt;grep&lt;/code&gt; works but &lt;br&gt;
matches values too — not just paths.&lt;/p&gt;

&lt;p&gt;For example if I search for "name" in my JSON:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;grep matches &lt;code&gt;json.user.name&lt;/code&gt; ✅ (correct)&lt;/li&gt;
&lt;li&gt;grep also matches &lt;code&gt;json.bio = "my name is Alice"&lt;/code&gt; ❌ (wrong)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I built &lt;strong&gt;jray&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  What jray does
&lt;/h2&gt;

&lt;p&gt;jray flattens any JSON into one line per value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;jray data.json
json.organization.name &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Acme Corporation"&lt;/span&gt;
json.users[0].name &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Alice Pemberton"&lt;/span&gt;
json.users[0].role &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"admin"&lt;/span&gt;
json.users[0].active &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true
&lt;/span&gt;json.billing.plan &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"enterprise"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can grep it, awk it, pipe it — using tools you already know.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four commands that cover everything
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Flatten with color output&lt;/span&gt;
jray data.json

&lt;span class="c"&gt;# Fetch a URL directly — no curl needed&lt;/span&gt;
jray https://jsonplaceholder.typicode.com/users/1

&lt;span class="c"&gt;# Filter by path only (never matches values)&lt;/span&gt;
jray data.json &lt;span class="nt"&gt;--filter&lt;/span&gt; &lt;span class="s2"&gt;"billing"&lt;/span&gt;

&lt;span class="c"&gt;# Extract any subtree as clean JSON&lt;/span&gt;
jray data.json &lt;span class="nt"&gt;--select&lt;/span&gt; &lt;span class="s2"&gt;"billing"&lt;/span&gt;

&lt;span class="c"&gt;# Print just the values&lt;/span&gt;
jray data.json &lt;span class="nt"&gt;--values&lt;/span&gt;

&lt;span class="c"&gt;# Reconstruct original JSON&lt;/span&gt;
jray data.json | jray &lt;span class="nt"&gt;--ungron&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The comparison with existing tools
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;jray&lt;/th&gt;
&lt;th&gt;jq&lt;/th&gt;
&lt;th&gt;gron&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Flatten to lines&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reconstruct JSON&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Filter by path&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Extract subtree&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fetch from URLs&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Color output&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No query language&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TypeScript / modern&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What I learned building it
&lt;/h2&gt;

&lt;p&gt;This was my first open source CLI tool. Key lessons:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Separate your CLI from your logic&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;cli.ts&lt;/code&gt; handles only I/O — reading files, printing output.&lt;br&gt;
&lt;code&gt;flatten.ts&lt;/code&gt;, &lt;code&gt;filter.ts&lt;/code&gt; etc. know nothing about terminals.&lt;br&gt;
This makes everything testable in isolation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Use &lt;code&gt;unknown&lt;/code&gt; not &lt;code&gt;any&lt;/code&gt; in TypeScript&lt;/strong&gt;&lt;br&gt;
JSON is dynamic but that doesn't mean &lt;code&gt;any&lt;/code&gt;. Using &lt;code&gt;unknown&lt;/code&gt; &lt;br&gt;
forces you to check types before using values — much safer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Recursive functions are perfect for JSON&lt;/strong&gt;&lt;br&gt;
JSON is a tree. Walking a tree with recursion is the &lt;br&gt;
cleanest pattern — each call handles one node and &lt;br&gt;
delegates children back to itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Bun is genuinely fast and simple&lt;/strong&gt;&lt;br&gt;
Native TypeScript, built-in fetch, fast startup. &lt;br&gt;
For a CLI tool, Bun is a great choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. The README matters as much as the code&lt;/strong&gt;&lt;br&gt;
Nobody uses a tool they can't understand in 30 seconds.&lt;br&gt;
Writing clear examples with real output is as important &lt;br&gt;
as writing the code itself.&lt;/p&gt;
&lt;h2&gt;
  
  
  Install and try it
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @siyadkc/jray
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jray https://jsonplaceholder.typicode.com/users/1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;GitHub: &lt;a href="https://github.com/siyadhkc/Jray" rel="noopener noreferrer"&gt;github.com/siyadhkc/Jray&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;for more info Website: &lt;a href="https://siyadhkc.github.io/Jray/" rel="noopener noreferrer"&gt;https://siyadhkc.github.io/Jray/&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;This is my first open source tool. Feedback on the code &lt;br&gt;
quality is very welcome — especially from experienced &lt;br&gt;
TypeScript developers!&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>bunjs</category>
      <category>opensource</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
