Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>HTTP Syntax HighlighterNew to Visual Studio Code? Get it now.
HTTP Syntax Highlighter

HTTP Syntax Highlighter

Cameron Bell

|
1 install
| (0) | Free
Syntax highlighting for .http and .rest request files
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

logo
HTTP Syntax Highlighter

A lightweight VS Code extension that provides basic syntax highlighting for .http and .rest files, the request-file format used by REST Client, JetBrains HTTP Client and Visual Studio. It only adds a grammar entry; it does not send requests.

What gets highlighted

  • Request lines. Method, URL, query parameters and HTTP/1.1. A bare https://... line also counts as a request.
  • Query strings split over several indented ? / & lines.
  • Headers, until the first blank line. Header names can contain variables ({{name}}: value).
  • ### separators. Any text after ### shows as the request title.
  • # and // comments, plus directives such as # @name login, # @prompt password and # @no-redirect.
  • File variables (@host = example.com).
  • {{variables}} everywhere, including inside JSON and XML bodies. System variables like {{$guid}} and {{$randomInt 1 10}} get their own colour.
  • Request bodies. The first non-blank body line picks the language:
    • { or [ starts JSON
    • <?xml or <tag starts XML
    • query, mutation, subscription or fragment starts GraphQL (full colouring needs a GraphQL extension)
    • --boundary starts a multipart body
    • key=value starts a form-urlencoded body
  • File includes (< ./body.json, <@ ./body.json, <@latin1 ./body.json).
  • JetBrains response handlers (> {% ... %}, > ./handler.js), pre-request scripts (< {% ... %}), output redirects (>> ./out.json, >>! ./out.json) and response references (<> ./previous.json). Script blocks are highlighted as JavaScript.

A body always ends at the next ### line, even if the JSON or XML above it is broken.

The same highlighting applies to ```http and ```rest code blocks in Markdown files.

Try it

Open this folder in VS Code and press F5. A new window opens with examples/sample.http loaded.

To install it for everyday use, package it and install the .vsix:

npx @vscode/vsce package
code --install-extension vscode-http-highlight-0.2.1.vsix

Tests

npm install
npm test

The tests run the grammar through vscode-textmate, the tokenizer VS Code uses, and check scopes on known inputs. The JSON, XML and JavaScript body tests load those grammars from the tm-grammars package, so they don't need VS Code installed.

One test compares the tokens for examples/sample.http with a snapshot in test/grammar.test.js.snapshot. If you change the grammar or the sample on purpose, check the new output and update the snapshot with npm run test:update-snapshots. This needs Node 22.13 or later.

Known limits

  • The extension registers the http language id. REST Client registers the same id, so if both are installed one grammar wins. You only need this extension when REST Client isn't installed.
  • Requests must be separated by ###. Without it, a second request line after a body is treated as body text.
  • A GraphQL body that starts with { (shorthand query) is highlighted as JSON.

Credits

The Markdown code block patterns in syntaxes/http.markdown.tmLanguage.json are adapted from the fenced code block rules in VS Code's Markdown grammar (microsoft/vscode-markdown-tm-grammar, MIT).

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft