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

stdin-glob

v1.4.0

Published

Expand glob patterns and output file contents.

Downloads

697

Readme

stdin-glob

npm version npm license TypeScript
GitHub stars

A simple CLI tool that expands glob patterns and outputs file contents or paths. Perfect for quickly previewing multiple files matching a pattern.

Why?

This tool solves a common pain point: aggregating file contents into a single, coherent output. Whether you're doing code reviews, documentation, or working with LLMs, having to manually copy-paste multiple files is tedious and error-prone.

I created this for my personal workflow when working with Large Language Models (LLMs). Combined with clipboard tools, it lets me instantly gather specific project context:

stdin-glob "src/**/*.ts" "src/**/*.tsx" | pbcopy  # On macOS
# or
stdin-glob "src/**/*.js" | xclip -selection clipboard  # On Linux

This pipes all relevant TypeScript/TSX files directly into my clipboard, ready to paste into ChatGPT, Claude, or any other LLM. Perfect for getting targeted, comprehensive context without the friction of opening and copying files one by one.

Features

  • Expand glob patterns to find matching files
  • Output file contents with syntax highlighting markers
  • Limit output to a specific number of lines per file with --max-lines
  • Show line numbers with --line-numbers for better code reference
  • Auto-copy output directly to clipboard with --copy flag
  • Support for absolute or relative paths
  • Option to show only file paths without content
  • Intelligent handling of binary files - shows metadata instead of attempting to display unreadable content
  • Automatic .gitignore filtering - respects your project's ignore rules by default
  • Written in TypeScript

Installation

npm install -g stdin-glob

Usage

stdin-glob [options] [patterns...]

Options

| Option | Description | | --------------------- | --------------------------------------------------------------------------- | | --no-content | Do not show file contents, only list matching paths | | --absolute | Show absolute paths for entries | | -c, --copy | Copy the output to clipboard instead of printing to console | | -m, --max-lines <n> | Show only the first N lines of each file (shows full file if omitted) | | -n, --line-numbers | Display line numbers next to each line, like in IDE sidebars | | --no-gitignore | Disable .gitignore filtering (include files that would normally be ignored) | | -V, --version | Output the version number | | -h, --help | Display help information |

Arguments

| Argument | Description | | ---------- | ------------------------------------------ | | patterns | Glob patterns to match files (one or more) |

Pattern Syntax

This tool uses fast-glob for pattern matching, which supports the feature set of picomatch. For detailed information about available globbing features and syntax options, refer to the picomatch globbing features documentation.

Examples

Basic usage

Display contents of all JavaScript files with syntax highlighting markers:

stdin-glob "src/**/*.js" --content
# or
stdin-glob "src/**/*.js"

Output:

```js
// src/index.js

console.log('Hello, world!');
```

```js
// src/utils/helpers.js

function add(a, b) {
  return a + b;
}
```

Limit lines per file

Show only the first 10 lines of each TypeScript file - perfect for quick overviews:

stdin-glob "src/**/*.ts" --max-lines 10

Output:

```ts
// src/index.ts

import { Command } from 'commander';
import { version } from '../package.json';
import { readFile } from 'fs/promises';
import glob from 'fast-glob';
import path from 'path';
import clipboard from 'clipboardy';
// ... (23 more lines truncated)
```

Show line numbers

Display line numbers alongside the code, just like in your editor:

stdin-glob "src/**/*.js" --line-numbers

Output:

```js
// src/index.js

 1 | import { Command } from 'commander';
 2 | import { version } from '../package.json';
 3 | import { readFile } from 'fs/promises';
 4 | import glob from 'fast-glob';
 5 | import path from 'path';
```

Combine with line limits

Get a preview with line numbers for better context:

stdin-glob "src/**/*.ts" --max-lines 5 --line-numbers

Output:

```ts
// src/index.ts

 1 | import { Command } from 'commander';
 2 | import { version } from '../package.json';
 3 | import { readFile } from 'fs/promises';
 4 | import glob from 'fast-glob';
 5 | import path from 'path';
// ... (23 more lines truncated)
```

Copy to clipboard

Copy all TypeScript file contents directly to clipboard:

stdin-glob "src/**/*.ts" --copy

This will copy the formatted output to your clipboard without printing to console. You'll see a confirmation message:

-> Output copied to clipboard successfully!

Now you can paste (Ctrl+V or Cmd+V) anywhere - perfect for sharing code in pull requests, documentation, or with LLMs.

Only list files

List all TypeScript files in the src directory without content:

stdin-glob "src/**/*.ts" --no-content

Output:

src/index.ts
src/utils/helpers.ts
src/types/index.ts

Multiple patterns

Match files with different extensions:

stdin-glob "src/**/*.ts" "src/**/*.js" --content

Absolute paths

Show absolute paths instead of relative ones:

stdin-glob "src/**/*.ts" --absolute --no-content

Output:

/home/pedrito/project/src/index.ts
/home/pedrito/project/src/utils/helpers.ts
/home/pedrito/project/src/types/index.ts

Binary file handling

When encountering binary files (like images, compiled binaries, etc.), the tool safely displays metadata instead of attempting to show unreadable content:

```png
// assets/logo.png
// [BINARY FILE] - Size: 0.024 MB
```

Integration with other commands

Use with grep to search for specific content:

stdin-glob "src/**/*.ts" | grep "function"

Or combine with other clipboard tools for maximum flexibility:

# Copy without the confirmation message
stdin-glob "src/**/*.ts" --no-content | pbcopy

# Preview first, then copy if it looks good
stdin-glob "src/**/*.ts" --content
stdin-glob "src/**/*.ts" --copy

.gitignore Support

By default, stdin-glob automatically respects your project's .gitignore rules. This means files and directories listed in .gitignore won't appear in the output. This is especially useful when you want to avoid including build artifacts, dependencies, or environment files in your context.

The gitignore pattern matching implementation is based on the official gitignore pattern format documentation, ensuring compatibility with how git itself handles ignore rules.

Including ignored files

If you need to include files that would normally be ignored, use the --no-gitignore flag:

stdin-glob "dist/**/*.js" --no-gitignore

This disables all .gitignore filtering and includes every file matching your patterns.