2024-04-12 22:53:16 +02:00
2025-06-07 22:43:20 +02:00
2024-04-27 20:34:37 +02:00
2024-04-27 20:46:09 +02:00
2024-04-27 20:58:05 +02:00
2025-06-06 12:55:07 +02:00
2025-06-07 22:32:29 +02:00
2025-06-06 12:55:07 +02:00

NOTICE: I'm slowly migrating my repositories to my own Git server. Please visit this repository at https://git.myzel394.app/Myzel394/jsonfly.nvim for the latest updates.

jsonfly.nvim

Fly through your JSON, XML and YAML files with ease. Search blazingly fast for keys via Telescope, navigate through your JSON structure with ease, and insert deeply nested keys without fear.

json(fly) is a Telescope extension that will show you all keys (including nested ones) in your JSON (or XML or YAML) files and allow you to search and jump to them quickly. It's completely customizable and even supports highlighting of the values.

Features

  • 🔍 Search for deeply nested keys - expo.android.imageAsset.0.uri
  • 👀 Insert nested keys quickly into your buffer
  • 🎨 See values with their correct syntax highlighting (numbers, strings, booleans, null; configurable)
  • 💻 Use your LSP or the built-in JSON parser
  • 🗑 Values automatically cached for faster navigation
  • 🫣 Automatic concealment based on your configuration
  • 📐 Everything completely customizable!
  • 📝 JSONPath support - copy JSON paths to your clipboard

Installation

Install with your favorite plugin manager, for example with lazy.nvim:

{
    "nvim-telescope/telescope.nvim",
    dependencies = {
        -- "https://git.myzel394.app/Myzel394/easytables.nvim",
        -- "https://git.myzel394.app/Myzel394/telescope-last-positions",
        -- Other dependencies
        -- ..
        "https://git.myzel394.app/Myzel394/jsonfly.nvim",
    }
}

Load the extension with:

require("telescope").load_extension("jsonfly")

Example

Here's how I load it with lazy.nvim with lazy-loading and <leader>j as the keymap :)

{
    "nvim-telescope/telescope.nvim",
    dependencies = {
        "https://git.myzel394.app/Myzel394/jsonfly.nvim",
    },
    keys = {
        {
            "<leader>j",
            "<cmd>Telescope jsonfly<cr>",
            desc = "Open json(fly)",
            ft = { "json", "xml", "yaml" },
            mode = "n"
        }
    }
}

Usage

Go to a JSON file and run:

:Telescope jsonfly

Now you can search for keys, subkeys, part of keys etc.

Inserting Keys

JSON(fly) supports inserting your current search prompt into your buffer.

If you search for a key that doesn't exist you can add it to your buffer by pressing <C-a> (CTRL + a).

You can enter nested keys, arrays, indices, subkeys etc. JSON(fly) will automatically manage everything for you.

The following schemas are valid:

  • Nested keys: expo.android.imageAssets.
  • Array indices: expo.android.imageAssets.0.uri, expo.android.imageAssets.3.uri, expo.android.imageAssets.[3].uri
  • Escaping: expo.android.tests.\0.name -> Will not create an array but a key with the name 0

Please note: JSON(fly) is intended to be used with human-readable JSON files. Inserting keys won't work with minified JSON files.

Integrating jsonpath.nvim

json(fly) has native support for jsonpath.nvim.

Just make sure jsonpath is loaded when you call json(fly), and you can copy the currently selected path by pressing <C-j> (you can also change this keybinding of course).

Example:

{
    url = "https://git.myzel394.app/Myzel394/jsonfly.nvim",
    dependencies = {
        "phelipetls/jsonpath.nvim"
    },
},

See also

Configuration

Edit jsonfly like any other Telescope extension:

require"telescope".setup {
    extensions = {
        jsonfly = {
            -- Your configuration here
        }
    }
}

Please see jsonfly.lua for the default configuration. The first comment in the file contains a list of all available options.

Example: Vertical layout

require"telescope".setup {
    extensions = {
        jsonfly = {
            mirror = true,
            layout_strategy = "vertical",
            layout_config = {
                mirror = true,
                preview_height = 0.65,
                prompt_position = "top",
            },
            key_exact_length = true
        }
    }
}

Example: Horizontal layout

require"telescope".setup {
    extensions = {
        jsonfly = {
            layout_strategy = "horizontal",
            prompt_position = "top",
            layout_config = {
                mirror = false,
                prompt_position = "top",
                preview_width = 0.45
            }
        }
    }
}

Example: Waterfall keys

require"telescope".setup {
    extensions = {
        jsonfly = {
            subkeys_display = "waterfall"
        }
    }
}

Acknowledgements

Description
🦋❵ Fly through your JSON / XML / YAML files with ease. Search blazingly fast for keys via Telescope.
Readme 458 KiB
Languages
Lua 95.8%
Nix 4%
Just 0.2%