explaingit

joshuakgoldberg/unist-util-visit

Analysis updated 2026-07-08 · repo last pushed 2026-01-22

Audience · developerComplexity · 2/5MaintainedLicenseSetup · easy

TLDR

A small JavaScript utility that walks through document trees (like parsed Markdown) node by node, letting you inspect or modify each piece of text along the way.

Mindmap

mindmap
  root((repo))
    What it does
      Walks document trees
      Runs function per node
      Filters node types
    Use cases
      Spellcheckers
      Link rewriters
      Linters
    Tech stack
      TypeScript
      JavaScript
      Node.js
    Features
      Skip children
      Stop early
      Full node context
    Audience
      Developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Build a spellchecker that scans only text nodes in a Markdown document.

USE CASE 2

Create a tool that finds and rewrites all links in parsed content.

USE CASE 3

Write a linter that flags problematic formatting in structured documents.

What is it built with?

JavaScriptTypeScriptNode.js

How does it compare?

joshuakgoldberg/unist-util-visit0xhassaan/nn-from-scratch0xzgbot/hermes-comfyui-skills
Stars00
LanguagePython
Last pushed2026-01-22
MaintenanceMaintained
Setup difficultyeasymoderateeasy
Complexity2/54/51/5
Audiencedeveloperdeveloperdesigner

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Install via npm and pass it a parsed syntax tree along with a visitor function.

You can use, copy, modify, and distribute this software freely, including in commercial projects, as long as you include the copyright notice and license text.

In plain English

When you write something in Markdown, a tool converts your text into a tree-like structure where each piece, a paragraph, a bold word, a code snippet, becomes a "node." The unist-util-visit package gives developers a simple way to walk through that tree, stopping at each node along the way. It's essentially a tour guide for structured text content. The core idea is straightforward: you hand the tool your tree and a function. It then walks through every node in order and runs your function on each one. Your function can just look at the node (to find something specific, for instance), or it can change it entirely. As it walks, the tool gives your function context about where it is, the current node, its position (index) among its siblings, and its parent node. You can also filter which nodes to stop at, so you don't have to inspect every single one. Developers use this when they need to find, read, or modify specific parts of a document. For example, if you have a Markdown file and want to find every piece of plain text, you could use this tool to visit only "text" nodes and log their contents. It's the kind of utility you'd reach for when building something like a spellchecker, a tool that rewrites links, or a linter that flags problematic formatting, anything where you need to scan or transform structured content piece by piece. One thing worth noting is the fine-grained control it gives you over the walking process. At any point, your function can tell the tool to keep going as normal, stop entirely (useful once you've found what you need), or skip the children of the current node. This means you can bail out early or skip deeply nested sections you don't care about, which is helpful for performance when dealing with large documents. The project also includes TypeScript types, which helps developers catch mistakes before they run their code.

Copy-paste prompts

Prompt 1
Write a function using unist-util-visit that finds all link nodes in a Markdown AST and replaces their URLs with lowercase versions.
Prompt 2
Using unist-util-visit, write a visitor that logs every text node's value from this Markdown tree so I can see all plain text content.
Prompt 3
Create a unist-util-visit script that stops visiting as soon as it finds the first code block node and returns its contents.

Frequently asked questions

What is unist-util-visit?

A small JavaScript utility that walks through document trees (like parsed Markdown) node by node, letting you inspect or modify each piece of text along the way.

Is unist-util-visit actively maintained?

Maintained — commit in last 6 months (last push 2026-01-22).

What license does unist-util-visit use?

You can use, copy, modify, and distribute this software freely, including in commercial projects, as long as you include the copyright notice and license text.

How hard is unist-util-visit to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is unist-util-visit for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.