Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>WGSL FormatterNew to Visual Studio Code? Get it now.
WGSL Formatter

WGSL Formatter

bijingdabaihua

|
1 install
| (0) | Free
Intelligent code formatter for WebGPU Shading Language (WGSL) with automatic indentation, spacing, alignment, and line wrapping
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

WGSL Formatter

🎨 Professional code formatter for WebGPU Shading Language

Version License VSCode

English | 中文


✨ Features

  • 🚀 Lightning Fast - Format files in milliseconds
  • 🎯 Smart Formatting - Intelligent indentation and spacing
  • 📐 Auto Alignment - Beautiful struct field alignment
  • 🔄 Format on Save - Automatic formatting when you save
  • ⚙️ Highly Configurable - Customize to match your style
  • 🛡️ Error Tolerant - Handles syntax errors gracefully
  • 🌍 Cross-Platform - Works on Windows, macOS, and Linux

📦 Installation

Method 1: VSCode Marketplace

  1. Open VSCode Extensions (Ctrl+Shift+X / Cmd+Shift+X)
  2. Search for "WGSL Formatter"
  3. Click Install

Method 2: Quick Install

ext install wgsl-tools.wgsl-formatter

🚀 Quick Start

  1. Open any .wgsl file
  2. Press Shift+Alt+F (Windows/Linux) or Shift+Option+F (macOS)
  3. Done! Your code is now beautifully formatted ✨

Enable Format on Save

Add to your VSCode settings:

{
  "editor.formatOnSave": true,
  "[wgsl]": {
    "editor.defaultFormatter": "wgsl-tools.wgsl-formatter"
  }
}

📸 Before & After

Before After
struct Vertex{
@location(0) pos:vec3<f32>,
@location(1) normal:vec3<f32>,
}
fn main(v:Vertex)->vec4<f32>{
return vec4<f32>(v.pos,1.0);
}
struct Vertex {
    @location(0) pos:    vec3<f32>,
    @location(1) normal: vec3<f32>,
}

fn main(v: Vertex) -> vec4<f32> {
    return vec4<f32>(v.pos, 1.0);
}

⚙️ Configuration

Setting Default Description
wgslFormatter.indentSize 4 Spaces per indentation level
wgslFormatter.useTabs false Use tabs instead of spaces
wgslFormatter.maxLineLength 100 Maximum line length
wgslFormatter.enableLineWrapping true Enable automatic line wrapping

🎯 What Gets Formatted

✅ Indentation and nesting
✅ Operator spacing (=, +, -, *, /)
✅ Comma spacing
✅ Struct field alignment
✅ Function parameter alignment
✅ Blank line normalization
✅ Trailing whitespace removal

🤝 Contributing

Contributions are welcome! Please check out our Contributing Guide.

📝 License

MIT © WGSL Tools

🔗 Links

  • GitHub Repository
  • Issue Tracker
  • Changelog

✨ 功能特性

  • 🚀 极速格式化 - 毫秒级格式化速度
  • 🎯 智能格式化 - 智能缩进和空格处理
  • 📐 自动对齐 - 结构体字段自动对齐
  • 🔄 保存时格式化 - 保存文件时自动格式化
  • ⚙️ 高度可配置 - 自定义格式化风格
  • 🛡️ 容错处理 - 优雅处理语法错误
  • 🌍 跨平台支持 - 支持 Windows、macOS 和 Linux

📦 安装

方法 1:VSCode 扩展商店

  1. 打开 VSCode 扩展面板(Ctrl+Shift+X / Cmd+Shift+X)
  2. 搜索 "WGSL Formatter"
  3. 点击安装

方法 2:快速安装

ext install wgsl-tools.wgsl-formatter

🚀 快速开始

  1. 打开任意 .wgsl 文件
  2. 按 Shift+Alt+F(Windows/Linux)或 Shift+Option+F(macOS)
  3. 完成!代码已格式化 ✨

启用保存时格式化

在 VSCode 设置中添加:

{
  "editor.formatOnSave": true,
  "[wgsl]": {
    "editor.defaultFormatter": "wgsl-tools.wgsl-formatter"
  }
}

📸 格式化前后对比

格式化前 格式化后
struct Vertex{
@location(0) pos:vec3<f32>,
@location(1) normal:vec3<f32>,
}
fn main(v:Vertex)->vec4<f32>{
return vec4<f32>(v.pos,1.0);
}
struct Vertex {
    @location(0) pos:    vec3<f32>,
    @location(1) normal: vec3<f32>,
}

fn main(v: Vertex) -> vec4<f32> {
    return vec4<f32>(v.pos, 1.0);
}

⚙️ 配置选项

配置项 默认值 说明
wgslFormatter.indentSize 4 每级缩进的空格数
wgslFormatter.useTabs false 使用 Tab 而非空格
wgslFormatter.maxLineLength 100 最大行长度
wgslFormatter.enableLineWrapping true 启用自动换行

🎯 格式化内容

✅ 缩进和嵌套
✅ 运算符空格(=、+、-、*、/)
✅ 逗号后空格
✅ 结构体字段对齐
✅ 函数参数对齐
✅ 空行规范化
✅ 行尾空格清理

🤝 参与贡献

欢迎贡献代码!请查看我们的贡献指南。

📝 开源协议

MIT © WGSL Tools

🔗 相关链接

  • GitHub 仓库
  • 问题反馈
  • 更新日志

Made with ❤️ for WebGPU developers

If you find this extension helpful, please ⭐ star the repo!

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