Skip to content
Convert a file system tree to a blob of json
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Command line:


usage: fsj [files] [-lhf] [-d int] [-t exec] [-i regex]
    Writes a json blob to stdout, with all the contents of all the files in it.

    If no arguments are specified, reads a whitespace delimited list of files
    from stdin, and builds a bundle from their contents once it receives EOF.


    -d, --indent:

       formats the resulting json with the specified number of spaces 

    -h, --help:

        Print this help message, and exit.

    -l, --links:

        follow symbolic links, recursively descending whatever the
        link points to, as well.

    -i, --ignore regex:

        Paths matching this JavaScript regex are excluded

    -t, --file-transform

        The path to an executable process that listens for file data on stdin
        and writes some transform of the above to stdout. For example:

          fsj -t $(grep ack)

        will result in a json blob whose values are only those lines containing

    -f, --flat
        Whether the resulting json blob should unify paths and return a nested
        blob, or a flat json blob. For example, with flat specified, the
        resulting blob might be:

                'my-proj/help.txt': 'text',
                'my-proj/chpater1/intro.txt': 'text',
                'my-proj/chpater1/body.txt': 'text',
                'my-proj/chpater1/conclusion.txt': 'text',
                'my-proj/chpater2/body.txt': 'text'

        With flat set to false, it owuld be:

                'my-proj': {
                    'help.txt': 'text'
                    'chpater1': {
                        /intro.txt': 'text',
                        'body.txt': 'text',
                        'conclusion.txt': 'text'
                    'chpater2': {
                        'body.txt': 'text'


var fsj = require('fsj')

fsj(stream, options, ready)
  • stream: a readable stream which emits paths to walk
  • options: options keyed and defined by the logform of the command line arguments listed below
  • ready: a callback when its all been walked. Will be called with the json blob defined in the command line section
You can’t perform that action at this time.