Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Fixed Length Files to JSONNew to Visual Studio Code? Get it now.
Fixed Length Files to JSON

Fixed Length Files to JSON

Carson

|
402 installs
| (2) | Free
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

fixed-to-json README

Instructions

Basic Usage

In your settings.json file add the following object

"fixedColumns": {
    "example": [
        {
            "name": "Field 1",
            "start": 0,
            "length": 5
        },
        {
            "name": "Field 2",
            "start": 5,
            "length": 10
        }
    ]
}

Then by running the extension and using the example layout, a file that looks like this:

111112222222222

Will be transformed into this

[
  {
    "Field 1": "11111",
    "Field 2": "2222222222"
  }
]

More Features

If your fixed length file has repeated fields that would be best represented by an array, use the repeat field in your settings.json file.

For example, by adding this to your settings.json file:

"fixedColumns": {
    "repeated": [
        {
            "start": 0,
            "length": 10,
            "name": "Field 1"
        },
        {
            "name": "Repeating Field",
            "start": 10,
            "length": 7,
            "repeat": 6
        }
    ]
}

A file that looks like this:

field 1   line 1 line 2 line 3 line 4 line 5 line 6

Will be transformed into this:

[
  {
    "Field 1": "field 1",
    "Repeating Field": [
      "line 1",
      "line 2",
      "line 3",
      "line 4",
      "line 5",
      "line 6"
    ]
  }
]

If you don't want to see blank JSON entries you can set the hideBlanks field to true.

For example using a configuration looking like this:

"fixedColumns": {
    "hideBlanks": true,
    "test": [
        {
            "start": 0,
            "length": 10,
            "name": "Field 1"
        },
        {
            "start": 10,
            "length": 10,
            "name": "Field 2"
        }
    ]
}

On a text file like this

          Field 2

Will look like this

[
  {
    "Field 2": "Field 2"
  }
]

1.0.1

Can now hide blank entries

1.0.0

Added repeated keyword to create JSON arrays

0.0.1

Added functionality to parse fixed length files to JSON

Enjoy!

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft