npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tree-sitter-containerfile

v0.8.0

Published

A Containerfile and Dockerfile grammar for tree-sitter

Readme

tree-sitter-containerfile

A maintained Containerfile and Dockerfile grammar for tree-sitter.

This project is intended to be a reliable, actively maintained grammar for modern container build files, with published packages and generated bindings for Node.js, Python, Rust, Go, Swift, and C.

Why This Package

Containerfile and Dockerfile syntax continues to evolve across Docker, BuildKit, Podman, and related tooling. This grammar aims to close the gap for modern Dockerfile features, keep real-world fixtures parsing cleanly, and ship usable packages across the common tree-sitter binding ecosystems.

The historical tree-sitter-dockerfile npm package is not a dependable installation target: it currently resolves to a 0.0.1-security placeholder release. tree-sitter-containerfile is the maintained package name for this grammar and its generated artifacts.

Installation

npm

npm install tree-sitter-containerfile

PyPI

pip install tree-sitter-containerfile

Cargo

cargo add tree-sitter-containerfile

Go

import containerfile "github.com/wharflab/tree-sitter-containerfile"

Usage

Node.js

import Parser from "tree-sitter";
import Containerfile from "tree-sitter-containerfile";

const parser = new Parser();
parser.setLanguage(Containerfile);

const tree = parser.parse("FROM alpine:3.20\nRUN echo ok\n");
console.log(tree.rootNode.toString());

Python

from tree_sitter import Language, Parser
import tree_sitter_containerfile

parser = Parser(Language(tree_sitter_containerfile.language()))
tree = parser.parse(b"FROM alpine:3.20\nRUN echo ok\n")
print(tree.root_node.sexp())

Rust

let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_containerfile::LANGUAGE;
parser.set_language(&language.into()).unwrap();

let tree = parser.parse("FROM alpine:3.20\nRUN echo ok\n", None).unwrap();
println!("{}", tree.root_node().to_sexp());

Go

package main

import (
	"fmt"

	sitter "github.com/tree-sitter/go-tree-sitter"
	containerfile "github.com/wharflab/tree-sitter-containerfile"
)

func main() {
	parser := sitter.NewParser()
	defer parser.Close()

	_ = parser.SetLanguage(containerfile.GetLanguage())
	tree := parser.Parse([]byte("FROM alpine:3.20\nRUN echo ok\n"), nil)
	defer tree.Close()

	fmt.Println(tree.RootNode().ToSexp())
}

Development

npm ci
npm run generate
tree-sitter test

The test suite includes the upstream corpus and integration parsing of the real-world Containerfile fixtures in examples/.

Migration Notes

Spaced ENV values can span line continuations. Consumers that inspect unquoted_string children should handle line_continuation nodes in addition to expansion nodes, because the internal _spaced_env_value rule aliases those values to unquoted_string.

Credits

This grammar started from camdencheek/tree-sitter-dockerfile. The project is being maintained and extended here under the tree-sitter-containerfile package name.

License

Licensed under MIT.

The original MIT notice for the upstream grammar and fixtures is preserved in LICENSE-MIT-CamdenCheek.