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

analyze-project-structure

v2.0.1

Published

CLI tool for analyzing and printing the folder structure of a project, extracting details about files (such as functions, variables, routes, and imports/exports), and summarizing the project's code organization.

Readme

Analyze Project Structure

A command-line tool to analyze and print the folder structure of JavaScript/TypeScript projects, extracting detailed insights about files, including functions, variables, routes, imports, and exports. It helps summarize the organization of your project’s codebase.

Features

  • Recursively prints the folder structure starting from the current directory (or specified folder).
  • Extracts detailed info from source files, including:
    • Functions (regular and arrow functions)
    • Variables (including constants)
    • Routes (GET, POST, etc. with handler details)
    • Imports and exports
  • Supports popular frameworks with enhanced parsing:
    • Angular (components, services, imports, functions)
    • Express (routes, imports, classes, functions, variables)
    • React (components, hooks, imports, functions)
  • Outputs a clean, tree-like formatted text file or JSON file for easy reading.
  • Default output file is folder-structure-output.txt in text format, customizable via command line.
  • Supports output in JSON format by specifying the format argument.

Installation

Global Installation

Install the tool globally to run from anywhere:

npm install -g analyze-project-structure

Local Installation

Install as a development dependency in your project:

npm install analyze-project-structure --save-dev

Usage

Run the tool from your project root directory (where package.json and source folders like src exist):

analyze-project-structure [outputFile] [outputFormat]

or using the alias:

aps [outputFile] [outputFormat]
  • outputFile (optional): Specify a custom output file name. Defaults to folder-structure-output.txt.
  • outputFormat (optional): Specify the output format, either text (default) or json.

Examples

Generate the default output file in text format:

analyze-project-structure

or

aps

Generate output with a custom file name in text format:

analyze-project-structure my-output.txt

or

aps my-output.txt

Generate output in JSON format with default file name:

analyze-project-structure folder-structure-output.json json

or

aps folder-structure-output.json json

Generate output in JSON format with custom file name:

analyze-project-structure my-output.json json

or

aps my-output.json json

Example Output (Text)

The generated text file will show a detailed, nested folder and file structure with extracted code details. For example:

├── routes
│   ├── appointment.ts
│   │   ├── Routes
│   │   │   ├── /
│   │   │   │   ├── GET
│   │   │   │   │   ├── Handler Variables
│   │   │   │   │   │   └── user
│   │   │   │   │   └── Functions in Handler
│   │   │   │   │       └── Anonymous Arrow Function
│   │   │   │   └── POST
│   │   │   │       ├── Handler Variables
│   │   │   │       │   └── appointment
│   │   │   │       └── Functions in Handler
│   │   │   │           └── Anonymous Arrow Function
│   │   ├── Imports
│   │   │   ├── express
│   │   │   └── ../../db
│   │   ├── Exports
│   │   │   └── appointmentRouter
│
│   └── auth.ts
│       ├── Routes
│       │   └── /register
│       │       └── POST
│       ├── Imports
│       │   ├── express
│       │   ├── bcryptjs
│       │   ├── jsonwebtoken
│       │   ├── express-validator
│       │   └── ../../db
│       ├── Exports
│       │   └── authRoutes
│
├── server.ts
│   ├── Imports
│   │   ├── express
│   │   ├── helmet
│   │   ├── ./routes/auth
│   │   └── ./routes/appointment

Example Output (JSON)

The generated JSON file will contain the same structure in a JSON object format, suitable for programmatic consumption.

{
  "routes": {
    "appointment.ts": {
      "routes": [
        {
          "path": "/",
          "methods": [
            {
              "type": "GET",
              "handlerVariables": ["user"],
              "functions": ["Anonymous Arrow Function"]
            },
            {
              "type": "POST",
              "handlerVariables": ["appointment"],
              "functions": ["Anonymous Arrow Function"]
            }
          ],
          "imports": ["express", "../../db"],
          "exports": ["appointmentRouter"]
        }
      ]
    },
    "auth.ts": {
      "routes": [
        {
          "path": "/register",
          "methods": [
            {
              "type": "POST"
            }
          ],
          "imports": [
            "express",
            "bcryptjs",
            "jsonwebtoken",
            "express-validator",
            "../../db"
          ],
          "exports": ["authRoutes"]
        }
      ]
    }
  },
  "server.ts": {
    "imports": [
      "express",
      "helmet",
      "./routes/auth",
      "./routes/appointment"
    ]
  }
}

Supported Frameworks

  • Angular: Detects components, services, imports, and functions by parsing decorators.
  • Express: Detects routes, imports, classes, functions, and variables.
  • React: Detects components, hooks, imports, and functions.

The tool automatically detects the project type from your package.json dependencies and adjusts parsing accordingly.

License

This project is licensed under the ISC License - see the LICENSE file for details.

Author

Prasad Dhule