HTTP Language
Full language support for HTTP requests in VS Code - syntax, auto-completion, and more.
REST Client Next provides comprehensive language support for HTTP request files with .http and .rest extensions. This includes syntax highlighting, auto-completion, code snippets, navigation, and more.
Activation
The HTTP language mode is automatically activated when:
- File has extension
.httpor.rest - First line follows standard RFC 2616 request line format:
Method SP Request-URI SP HTTP-Version
To manually enable, click the language mode indicator in VS Code’s status bar (bottom-right) and select HTTP.
Syntax Highlighting
- Request line - Method, URL, HTTP version
- Headers - Header names and values
- Body - Content with appropriate highlighting based on MIME type (JSON, XML, JavaScript, etc.)
- Comments - Lines starting with
#or// - Responses - When previewing responses, syntax highlighting is applied
Auto-Completion
Auto-completion triggers automatically or with Ctrl+Space. Supported categories:
- HTTP Methods - GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, etc.
- HTTP URLs - From request history
- HTTP Headers - Standard and custom headers
- System Variables -
{{$guid}},{{$timestamp}}, etc. - Custom Variables - Environment, file, and request variables in current context
- MIME Types - For
AcceptandContent-Typeheaders - Authentication Schemes - Basic, Digest, AWS, etc.
Code Snippets
Built-in snippets accelerate request authoring:
| Snippet | Description |
|---|---|
get |
GET request template |
post |
POST request template |
put |
PUT request template |
delete |
DELETE request template |
patch |
PATCH request template |
head |
HEAD request template |
options |
OPTIONS request template |
Type the snippet name and press Tab to expand.
Comments
Both comment styles are supported:
# This is a comment
// This is also a comment
GET https://api.example.com/users
Comments can appear anywhere in the file.
JSON & XML Support
Body Indentation
When pressing Enter inside {}, [], or <> brackets, automatic indentation is applied (configurable via rest-client.addRequestBodyLineIndentationAroundBrackets).
Auto-Closing Brackets
Type {, [, (, ", or ' and the closing character is automatically inserted.
Comment Conversion
Select code and type // or # to comment/uncomment multiple lines.
Goto Symbol
Navigate to requests and variables quickly:
- Press
Ctrl+Shift+O(Cmd+Shift+Oon macOS) - Or press
F1and type@
Shows a list of:
- File-level variables (
@variableName) - Named requests (
# @name requestName) - Request blocks
Select to jump directly.
CodeLens
CodeLens displays actionable links above each request:
- Send Request - Send this request
- Send All Requests Sequentially - Send all requests in the file one after another
Toggle via:
rest-client.enableSendRequestCodeLensrest-client.enableCustomVariableReferencesCodeLens(shows variable references)
Customize titles:
rest-client.codeLensSendRequestTitlerest-client.codeLensSendAllRequestTitle
Folding
Request blocks can be folded/unfolded:
# @name myRequest
GET https://api.example.com/users
Authorization: Bearer token
# ... rest of request
Click the fold icon in the gutter or use:
Ctrl+Shift+[to foldCtrl+Shift+]to unfold
Markdown Code Blocks
REST Client recognizes HTTP requests within Markdown fenced code blocks:
```http
GET https://api.example.com/users
```
Language identifier http or rest both work.
File Associations
By default, .http and .rest extensions are associated with the HTTP language. To add custom associations, add to your settings.json:
{
"files.associations": {
"*.api": "http"
}
}
Manual Language Selection
If a file isn’t automatically recognized, change language mode:
- Click language indicator in status bar (bottom-right)
- Select HTTP from list
- Or press
Ctrl+K M(Cmd+K Mon macOS) and choose HTTP
Language Features Summary
| Feature | Description |
|---|---|
| Syntax highlighting | Requests, headers, bodies, comments |
| Auto-completion | Methods, URLs, headers, variables, MIME types |
| Snippets | Templates for common HTTP methods |
| Goto Symbol | Navigate to variables and named requests |
| CodeLens | Inline “Send Request” links |
| Folding | Collapse/expand request blocks |
| Comment toggling | # and // support |
| Bracket matching & auto-closing | {}, [], (), “”, ‘’ |
| Indentation | Smart indentation around brackets |
| Markdown support | Recognize requests in fenced code blocks |
Tips
- Save your file - Some features (like variable resolution, diagnostics) work best with saved files
- Use named requests -
# @namemakes goto symbol and variable references more useful - Define file variables -
@variable = valueat the top for reusable values - Leverage auto-completion - Start typing variables, headers, or methods to see suggestions
- CodeLens is your friend - Keep it enabled for quick one-click sending
Troubleshooting
No syntax highlighting?
- Ensure file extension is
.httpor.rest - Or manually set language mode to HTTP
Auto-completion not working?
- Check that language mode is HTTP
- Wait for language server to initialize (~1-2 seconds after opening)
- Try
Ctrl+Spaceto manually trigger
CodeLens missing?
- Verify
rest-client.enableSendRequestCodeLensistrue - CodeLens may be disabled globally in VS Code:
editor.codeLenssetting - Some themes hide CodeLens; try changing theme or adjusting
workbench.colorCustomizations
Goto Symbol not showing variables?
- Ensure file variables start with
@on their own line - Named requests must use
# @nameor// @namesyntax - File must be saved for registration
Performance Tips
For large files (100+ requests):
- Disable CodeLens if slow:
"rest-client.enableSendRequestCodeLens": false - Disable variable reference CodeLens:
"rest-client.enableCustomVariableReferencesCodeLens": false - Consider splitting into multiple files
- Increase
rest-client.largeResponseBodySizeLimitInMBif dealing with large responses
Keyboard Shortcuts Reference
All shortcuts require HTTP/plaintext language mode:
| Action | Windows/Linux | macOS |
|---|---|---|
| Send Request | Ctrl+Alt+R |
Cmd+Alt+R |
| Cancel Request | Ctrl+Alt+K |
Cmd+Alt+K |
| Rerun Last Request | Ctrl+Alt+L |
Cmd+Alt+L |
| Request History | Ctrl+Alt+H |
Cmd+Alt+H |
| Switch Environment | Ctrl+Alt+E |
Cmd+Alt+E |
| Copy Request as cURL | Ctrl+Alt+C |
Cmd+Alt+C |
| Generate Code Snippet | Ctrl+Alt+C |
Cmd+Alt+C |
| Goto Symbol | Ctrl+Shift+O |
Cmd+Shift+O |
| Toggle Comment | Ctrl+/ |
Cmd+/ |
Note: These shortcuts are exclusive to HTTP/plaintext mode to avoid conflicts with other extensions.