AMPScript Engine
A VS Code extension for writing, previewing, and testing AMPScript templates locally — with live Salesforce Marketing Cloud data, no platform connection required during development.
Free vs Pro
AMPScript Engine has a free tier with essential language support, and a Pro tier for teams actively developing against Salesforce Marketing Cloud.
| Feature |
Free |
Pro |
| Syntax highlighting |
✅ |
✅ |
| Error diagnostics |
✅ |
✅ |
| Hover documentation |
✅ |
✅ |
| Basic autocomplete |
✅ |
✅ |
| Live preview |
❌ |
✅ |
| SFMC API connection |
❌ |
✅ |
| Download Data Extensions |
❌ |
✅ |
| Download Content Blocks |
❌ |
✅ |
| Push to SFMC |
❌ |
✅ |
| DE & column name suggestions |
❌ |
✅ |
| Content Block name suggestions |
❌ |
✅ |
| Signature help |
❌ |
✅ |
Upgrade to Pro at roclily.dev
Activating Pro
Once you have a license key, run:
AMPScript: Activate License
Enter your key when prompted. Your license is stored securely in VS Code's secret storage and validated automatically. Pro features are available immediately after activation — if VS Code was already open, reload the window once after activating.
To deactivate on a machine:
AMPScript: Deactivate License
Features
Free
Syntax Highlighting
Full AMPScript grammar with theme-aware colors for keywords, variables, strings, and operators in .ampscript and .amp files.
Error Diagnostics
Real-time red squiggles on syntax errors as you type, with descriptive messages pointing to the exact line and character.
Hover Documentation
Hover over any AMPScript function to see its full signature, parameter descriptions, return type, and a usage example.
Basic Autocomplete
Keyword and function name suggestions as you type, including all built-in AMPScript functions and language keywords.
Pro
Live Preview
Run any .ampscript file and see rendered HTML output instantly in a side panel. No test send required.
SFMC API Integration
Connect directly to one or more Marketing Cloud Business Units using an Installed Package. Add, switch between, and remove BU connections without leaving VS Code.
Download Data Extensions
Browse and download Data Extensions from your connected BU for local use in the preview engine and autocomplete.
Download Content Blocks
Browse and download Content Blocks from Content Builder so they resolve correctly during local preview.
Push to SFMC
Push your AMPScript source or rendered HTML back to Content Builder directly from VS Code.
DE & Column Name Suggestions
When typing functions like Lookup(), LookupRows(), or UpsertData(), the editor suggests your downloaded Data Extension names and their field names automatically.
Content Block Name Suggestions
When typing ContentBlockByName(), ContentBlockByKey(), or ContentBlockById(), the editor suggests your downloaded Content Blocks by name, key, or ID.
Signature Help
As you type function arguments, a tooltip shows which parameter you're currently on with its name, type, and description.
Getting Started
1. Initialize your project
Open a folder in VS Code and run:
AMPScript: Initialize Project
This creates .ampscript-data/ and .ampscript-blocks/ folders with a README explaining the structure, and adds them to .gitignore.
Add your Marketing Cloud installed package credentials to VS Code settings (Ctrl+,, search for ampscript):
| Setting |
Description |
ampscript.sfmc.clientId |
Installed Package Client ID |
ampscript.sfmc.clientSecret |
Installed Package Client Secret |
ampscript.sfmc.authUrl |
Auth URL (e.g. https://xxxxx.auth.marketingcloudapis.com) |
ampscript.sfmc.mid |
Business Unit MID |
Setting up an Installed Package in SFMC
- Go to Setup → Apps → Installed Packages
- Click New and give it a name (e.g.
AMPScript Engine)
- Under Components, add an API Integration with Server-to-Server type
- Grant the following scopes:
- Data → Data Extensions: Read, Write
- Assets → Documents and Images: Read, Write
- Assets → Saved Content: Read, Write
- Save and copy the Client ID, Client Secret, and Authentication Base URI
Tokens are cached securely in VS Code's secret storage and refresh automatically.
Data Extensions
Download a Data Extension
AMPScript: Select Data Extension
- Fetches all Data Extensions from your BU (including Shared DEs)
- Use the search box to filter by name
- Rows and field definitions are saved to
.ampscript-data/<DE Name>/
Use in AMPScript
Write Lookups exactly as you would in SFMC — no changes needed when deploying:
%%[
SET @firstName = Lookup('Bruins Season Ticket Holders', 'FirstName', 'EmailAddress', 'test@example.com')
SET @rows = LookupRows('Bruins Season Ticket Holders', 'AccountType', 'Corporate')
SET @count = RowCount(@rows)
FOR @i = 1 TO @count DO
SET @row = Row(@rows, @i)
SET @name = Field(@row, 'FirstName')
NEXT @i
]%%
Hello, %%=v(@firstName)=%%!
IntelliSense for Data Extensions
- Type
Lookup(' — shows a list of all downloaded DE names
- After selecting a DE name, type
, — shows field names from that DE
- Works for
Lookup, LookupRows, LookupOrderedRows, and related functions
Content Blocks
Download a Content Block
AMPScript: Select Content Block
- Fetches all Code Snippets (type 220) and HTML Blocks (type 197) from Content Builder
- Search by name or external key
- Downloads to
.ampscript-blocks/<Block Name>/ containing:
properties.json — asset ID, customer key, name, type, dates
data.json — the block content (AMPScript or HTML)
data.html — the block content as raw HTML
Use in AMPScript
%%[ /* By name */ ]%%
%%=ContentBlockByName('Email Header')=%%
%%[ /* By external key */ ]%%
%%=ContentBlockByKey('email-header-block')=%%
%%[ /* By asset ID */ ]%%
%%=ContentBlockById(12345)=%%
Push to SFMC
AMPScript: Push to SFMC
Push the current .ampscript file back to Content Builder. You will be prompted to choose:
What to push:
- Raw AMPScript Source — pushed as a Code Snippet asset
- Rendered HTML — the template is evaluated locally first, then the output is pushed as an HTML Block
How to identify the asset:
- Use filename — the filename (without extension) is used as the asset name
- Enter a custom name — specify any name and optional external key
- Update a downloaded block — choose from a list of blocks already in
.ampscript-blocks/
Running Templates
Open any .ampscript file and run:
AMPScript: Run Current File
Or click the ▶ button in the editor title bar.
Supported AMPScript syntax
VAR, SET — variable declaration and assignment
IF / ELSEIF / ELSE / ENDIF
FOR @i = 1 TO @n DO / NEXT
DO / WHILE
- Inline expressions:
%%=v(@variable)=%%
- Block expressions:
%%[ ... ]%%
- Single
' and double " quoted strings
- Block and line comments
Supported functions
| Category |
Functions |
| String |
Concat, Substring, Length, UpperCase, LowerCase, ProperCase, Trim, Replace, IndexOf, RegExMatch |
| Math |
Add, Subtract, Multiply, Divide, Mod, Abs, Round, Ceil, Floor, FormatNumber |
| Logical |
IIF, Empty, IsNull, Not |
| Date |
Now, DateAdd, DateDiff, FormatDate |
| Data |
Lookup, LookupRows, LookupOrderedRows, UpsertData, RowCount, Row, Field |
| Content |
ContentBlockByName, ContentBlockByKey, ContentBlockById |
| Encoding |
URLEncode, Base64Encode, Base64Decode, GUID |
| Output |
v() |
Project Structure
your-project/
├── .ampscript-data/
│ └── My Data Extension/
│ ├── rows.json
│ └── _columns.json
├── .ampscript-blocks/
│ └── Email Header/
│ ├── properties.json
│ ├── data.json
│ └── data.html
├── .gitignore
└── my-template.ampscript
.ampscript-data/ and .ampscript-blocks/ are local only and excluded from git by default.
Notes
- Multiple BUs — credentials are configured per workspace. To work with a different BU, update the MID and credentials in settings
- Shared DEs — both standard and shared Data Extensions are returned when fetching the DE list
- Variables — all AMPScript variables must start with
@
- Inline expressions — use
%%=v(@variable)=%% not %%=@variable=%%
Built by RocLily Dev — tools for Salesforce Marketing Cloud developers.