A simple and lightweight formatter for .http and .rest files in Visual Studio Code. This extension helps you keep your REST API request files clean and readable by formatting headers and JSON bodies.
- Format
.httpand.restfiles: Automatically formats your request files when you save them or trigger the format command. - Indent Headers: Indents request headers for better readability.
- Format JSON Bodies: Pretty-prints JSON bodies in your requests.
- Multiple Requests: Supports formatting files with multiple requests separated by
###. - Configurable Indentation: Customize the indentation for headers and JSON bodies through VS Code settings.
- Install the extension from the Visual Studio Code Marketplace.
- Open a
.httpor.restfile. - Run the "Format Document" command (
Shift+Option+Fon macOS,Shift+Alt+Fon Windows).
This extension contributes the following settings:
rest-formatter.header.indent: Number of spaces to indent headers.- Default:
0 - Range:
0-32
- Default:
rest-formatter.body.json.indent: Number of spaces to indent the root of the JSON body.- Default:
0 - Range:
0-10
- Default:
You can configure these settings in your settings.json file or through the VS Code settings UI.
Example settings.json:
{
"rest-formatter.header.indent": 4,
"rest-formatter.body.json.indent": 2
}- Documents larger than 5 MiB are intentionally not formatted to protect the VS Code extension host.
- Invalid or duplicate-key JSON bodies are left unchanged and reported once per formatting operation.
Enjoy!