Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>TIA Portal Language SupportNew to Visual Studio Code? Get it now.
TIA Portal Language Support

TIA Portal Language Support

J. Heilingbrunner

|
105 installs
| (0) | Free
Syntax highlighting for exported Siemens TIA Portal files
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

TIA Portal Language Support

Syntax highlighting for exported Siemens TIA Portal (Step 7) files.

TIA viewer

Search in project

Git diff view

Features

  • Syntax highlighting for SCL, AWL / STL, DB, UDT, S7DCL and FBD sources.
  • UDT lookup from the workspace; views refresh when a file changes.
  • LAD networks drawn as ladder diagrams, with zoom.
  • FBD networks drawn as function block diagrams (&, >=1, =1 boxes, = / S / R assignments, operands at the pins).
  • Absolute addresses of PLC tags (%M1.2) in an address column next to STL operands and below the operands of LAD / FBD networks, looked up from the PLC tag tables of the workspace, like TIA Portal.
  • Fail-safe F-LAD / F-FBD / F-DB (safety programs): recognised in Openness XML (F_LAD, F_FBD, F_DB) and in SD format (S7_Safety), drawn like LAD / FBD / DB and labelled as fail-safe.
  • SCL / STL code with line numbers, folding and a REGION outline.
  • TIA Viewer: read-only, TIA-style view of Openness XML and .db, .udt, .s7dcl (with its .s7res), .scl, .awl, .stl files.
  • PLC tag tables in the layout of TIA's tag table editor, with Tags and User constants tabs.
  • AutomationML hardware exports (.aml) as tables of devices, network nodes, links and I/O tags.
  • Interface table with expandable structs, arrays and UDT members.
  • Collapsible networks (click a network heading, or use the collapse/expand all button in the header, which also folds the interface sections) and a culture setting for titles and comments.
  • git diff: both versions side by side, red/green marks, synchronized scrolling.
  • Search in project: a TIA-style search over all exported sources of a folder (right-click on software folder in the explorer).

Languages

Language Extensions Scope name
SCL .scl source.tia.scl
AWL / STL .awl, .stl source.tia.awl
DB .db source.tia.db
UDT .udt source.tia.udt
S7DCL .s7dcl source.tia.s7dcl
FBD .fbd source.tia.fbd

All grammars share the same scope suffix (.tia), so one theme rule such as keyword.control.tia applies to every language.

SCL – Structured Control Language

High-level, Pascal-like PLC language for function blocks, functions and organization blocks. This is the base grammar; the others reuse parts of it.

  • Block structure: FUNCTION_BLOCK, FUNCTION, ORGANIZATION_BLOCK, DATA_BLOCK, TYPE with their END_ counterparts, the block name, and REGION / END_REGION.
  • Interface sections: VAR, VAR_INPUT, VAR_OUTPUT, VAR_IN_OUT, VAR_TEMP, VAR_STAT with RETAIN / NON_RETAIN / CONSTANT, STRUCT, BEGIN, and the header lines TITLE, AUTHOR, FAMILY, NAME, VERSION.
  • Pragmas such as { S7_Optimized_Access := 'TRUE' }, including pragmas that span several lines.
  • Control flow: IF, CASE, FOR, WHILE, REPEAT, EXIT, CONTINUE, RETURN, GOTO.
  • Data types (elementary, Array, String[n], HW_* and similar) and quoted user types.
  • Literals: strings with $ escapes, based numbers (16#FF), typed literals (T#2s, DINT#5, LDT#…), TRUE / FALSE, numbers, and 0..127 ranges.
  • References: local tags (#name), global tags ("name"), members, %X0 slice access, built-in functions, named call parameters (name :=, name =>) and calls to quoted blocks.
  • Comments: //, (* … *) and (/* … */).

AWL / STL – Statement List

Instruction-list language, one instruction per row. A source file is split into a header and a body:

  • Before BEGIN: the SCL grammar highlights the header, pragmas and VAR sections.
  • From BEGIN to the END_* of the block: AWL rules apply, and each statement may carry a leading label.

Highlighted in the body:

  • NETWORK and TITLE = … lines.
  • Labels (next:) and jump targets (JC next).
  • Instructions in the English and German mnemonic sets, grouped as logic (A/U, O, X, S, R, =, A( … ), word logic), arithmetic, comparison (==I, >R), load / transfer / convert / shift / timer / counter, jumps, calls (CALL, CC, UC) and program control (BE, OPN, MCR().
  • Operands: absolute addresses (I0.1, MW10, DB1.DBX0.0, T 5, FC 10), symbolic tags ("Tag", #local), registers AR1 / AR2, pointers (P#M 10.0) and constants (L#-5, W#16#FF, S5T#2s, B#(1, 2), TOD#…).
  • Call parameter lists with := and =>.
  • Comments: // and (* … *).

The mnemonic and operand rules follow the standard S7 instruction set. They have been checked against hand-written samples, not against real exports, so please report anything that is mis-scoped.

DB – Data Block

Global and instance data blocks (DATA_BLOCK "Name" … END_DATA_BLOCK).

  • Everything from the SCL grammar: header lines, the block-level pragma ({ S7_Optimized_Access := 'FALSE' }), VAR / STRUCT member declarations with their attribute pragmas ({ ExternalAccessible := 'False'; … }), types, comments.
  • The instantiated function block of an instance DB: the quoted name on its own line, for example "FB_Motor".
  • Start values after BEGIN: the target path (Data.Event[3].TimeStamp) is highlighted as a member, and the value as a literal (LDT#…, DINT#…, T#…, strings).

UDT – User-Defined Type

PLC data types (TYPE "Name" … END_TYPE).

  • The UDT grammar is the SCL grammar: TYPE header, TITLE, VERSION, nested STRUCT … END_STRUCT, member attribute pragmas, quoted UDT references, Array[a..b] of …, String[n] and comments.
  • Initial values in declarations: plain and typed literals (:= 1.5, := T#2s, := BYTE#16#FF) and aggregate initializers ([(1, ()), (2, ())], [8(1.0)]).

S7DCL – SD Format

SD format sources of TIA Portal V20 and later (.s7dcl, texts in a sibling .s7res). The grammar adds its own rules on top of the SCL grammar:

  • Attribute lists in braces (S7_Optimized, S7_Access, …) with their names and values, and text ids (S7_MLC, S7_BlockTitle).
  • Block and member structure, storage modifiers (RETAIN, …), type names and member targets of start values.
  • Hex literals and the global scope prefix.
  • LAD source text: RUNG and wire#… names.
  • Everything else falls back to the SCL grammar.

FBD – Function Block Diagram source

FBD has no text format of its own: TIA Portal exports FBD networks as RUNG source inside SD format (.s7dcl) files. The FBD grammar (.fbd, scope source.tia.fbd) is that rung syntax on top of the S7DCL grammar, and the TIA Viewer uses it for FBD networks it cannot draw:

  • Logic boxes A / AND, O / OR, X / XOR, and the output boxes Coil, S_Coil, R_Coil, Return_Coil, JumpCoil / I_JumpCoil as instructions.
  • Instruction boxes (Move, Convert, Calculate, math, comparators, Sel, Mux, timers, counters, edge and flip-flop boxes) as instructions.
  • Box pins (en, eno, in1…, out, q, et, …) before := / => as parameters.
  • Label( … ), RUNG / END_RUNG, wire#… names and attribute blocks.
  • Fail-safe (F-LAD / F-FBD) instructions: the safety functions ESTOP1, FDBACK, MUTING, TWO_H_EN, SFDOOR, ACK_GL, ACK_OP and the F timers / counters F_TON, F_TOF, F_TP, F_CTU, F_CTD, F_CTUD. The S7DCL grammar highlights them in LAD source as well.

TIA Viewer

A read-only viewer for TIA Portal exports: Openness XML (*.xml) and the text sources *.db, *.udt, *.s7dcl, *.scl, *.awl and *.stl. Open a file with Reopen Editor With… > TIA Viewer, or run TIA: Open Viewer to the Side. Changes can be compared in the viewer too, see git diff. The setting tiaViewer.culture (for example de-DE) selects the language of titles and comments.

Openness XML (*.xml)

Blocks exported as Openness XML (FB, FC, OB). The viewer shows the interface table, block and network titles/comments and the networks:

  • LAD is drawn as a ladder diagram: contacts (incl. negated and edge), coils (S, R), OR branches, FB/FC calls with instance and parameters, timers, comparators, math and Move. Parts without a dedicated symbol are drawn as a generic box.
  • FBD is drawn as a function block diagram: no power rail, operands at the box inputs and outputs, logic boxes titled & (And), >=1 (Or) and =1 (Xor), coils as assignment boxes (=, S, R, RET, JMP), and FB/FC calls, timers, comparators, math and Move as boxes like in LAD.
  • F-LAD and F-FBD (fail-safe blocks, ProgrammingLanguage F_LAD / F_FBD) are drawn like LAD and FBD; the block header and the network heading say F-LAD / F-FBD. In SD format a block with S7_Safety := "TRUE" shows its LAD / FBD networks as F-LAD / F-FBD.
  • SCL and STL networks are shown as source text.
  • Absolute addresses: an operand that names a PLC tag ("Motor_On") gets the tag's address (%Q4.0) from the tag table exports (SW.Tags.PlcTagTable XML) found in the workspace: in a fixed column to the right of STL lines (a literal such as L 0 is repeated there, as TIA Portal does), and in small text below the operand of LAD / FBD contacts, coils and box inputs. Locals (#x), data block members and tags without address show none. The view refreshes when a tag table changes.
  • Block comment: the //// lines in front of BEGIN of an .awl / .stl / .scl source are the block comment; it is collapsed to its first line (//===...) under the block title and opens on click.

Callee block numbers (%FB1, %DB43) are not part of the export and are not shown.

PLC tag tables (*.xml)

A tag table exported as Openness XML (the files of the PLC tags folder) opens like the tag table editor of TIA Portal, with a Tags tab (name, data type, address, retain, accessible / writable / visible, comment) and a User constants tab (name, data type, value, comment). The comments follow the culture setting. A table that only holds constants, such as an enumeration, opens on the constants. The writable and visible flags are dimmed for a tag that is not accessible from HMI / OPC UA, as in TIA. Tag tables are not compared in the git diff view yet; both sides just show their table.

Data blocks (*.db)

The same view opens TIA data block sources (Reopen Editor With… > TIA Viewer on a .db file): a numbered table with name, data type, start value, retain, accessible/writable/visible/setpoint flags and comment. Start values that are only the type default are greyed, values assigned in the BEGIN section are applied, and structs, arrays and UDT members can be expanded. UDTs are looked up in the *.udt files of the workspace; a type without a .udt file stays a plain row. Instance data blocks show the function block they belong to.

User-defined types (*.udt)

Reopen Editor With… > TIA Viewer on a .udt file shows the table of TIA's type editor: name, data type, default value (type defaults greyed), accessible/writable/visible/setpoint flags, supervision and comment, without sections and without a retain column. Structs, arrays and referenced UDTs can be expanded; referenced types are looked up in the *.udt files of the workspace, and the view refreshes when one of them changes.

AutomationML hardware exports (*.aml)

The hardware export of TIA Portal (AutomationML / CAEX) is shown as tables. Open the .aml with Reopen Editor With… > TIA Viewer:

  • Devices: every device and device item with its type name, order number, position number, firmware version and comment.
  • Network: subnets, IO systems and nodes with type, address, subnet mask and PROFINET device name.
  • Links: each link between two ports or between a node and a subnet, as the two elements it connects (a link to an id the file does not contain shows the raw reference).
  • I/O tags: the PLC tags of the tag tables with data type, I/O type, address and length.
  • All elements: the whole hierarchy, indented by depth, so elements with other roles stay visible.

The header names the tool, version and date that wrote the file. Comments use the language of tiaViewer.culture when the file has it.

In a comparison (for example Open Changes in the Source Control view) both versions are marked like the other views: green rows and cells in the new version, red in the old one. Elements are matched by their id, tags by table and name, links by the two elements they connect. A tab that holds a difference shows a coloured dot, and the Next / Previous Difference buttons continue into the next tab that has one. A changed value that no column shows (for example BuiltIn) marks the name cell and lists the change in its tooltip.

SD format sources (*.s7dcl + *.s7res)

TIA Portal V20 and later exports types and blocks as Name.s7dcl with the texts in a sibling Name.s7res (same folder, same name). Open the .s7dcl with Reopen Editor With… > TIA Viewer:

  • TYPE is shown like a .udt, DATA_BLOCK like a .db (also instance data blocks, data blocks on a UDT and array data blocks). Comments, block title and block comment are read from the .s7res (the text of the S7_MLC, S7_BlockTitle and S7_BlockComment ids; tiaViewer.culture picks the language, de-DE is the fallback). Without a .s7res, or for an id it does not contain, the id itself is shown.
  • S7_Access / S7_Visibility become the accessible/writable/visible flags, S7_Setpoint the setpoint flag, S7_Optimized, S7_StandardRetain and VAR RETAIN the memory layout and retain columns. Start values after END_VAR are applied.
  • Below the block, a collapsed Texts (.s7res) table lists every id of the .s7res with its text. Texts that nothing refers to are greyed, ids the source uses that the .s7res does not contain are marked red.
  • Opening the .s7res itself with the TIA Viewer shows the .s7dcl it belongs to, so the pair works from either file.
  • Types are looked up in the *.udt and *.s7dcl files of the workspace. The view refreshes when the .s7dcl or its .s7res changes.
  • FUNCTION_BLOCK, FUNCTION and ORGANIZATION_BLOCK show the interface table (like an .scl source) above their code. S7_EditorMode := "SCL" marks a pure SCL block, shown with line numbers, highlighting and the REGION outline. A block with S7_PreferredLanguage := "LAD" is shown network by network, each following its own S7_Language: SCL networks as highlighted code, LAD networks drawn as ladder diagrams like those of Openness XML (a network the viewer cannot read stays syntax-highlighted source text, RUNG / wire#…), titles and comments from the .s7res.

SCL sources (*.scl)

Reopen Editor With… > TIA Viewer on an .scl file shows the interface table (Input, Output, InOut, Static, Temp, Constant, Return; default values greyed, retain, comments, UDT members expandable) above the code. The code pane has line numbers, syntax highlighting from this extension's SCL grammar, fold markers for IF, CASE, FOR, WHILE, REPEAT, REGION and multi-line comments, and a REGION outline on the left that scrolls to (and unfolds) the selected region. If the highlighter cannot be loaded the code is shown as plain text.

STL sources (*.awl, *.stl)

The same view opens STL block sources: the interface table above one block per NETWORK, each with its title, the comment lines below the title and a numbered, syntax-highlighted listing of the instructions (English or German mnemonics, labels, absolute addresses, block calls). SCL and STL networks inside Openness XML exports are shown the same way.

Search in project

Right-click a folder in the Explorer and choose TIA: Search in Folder… (or run TIA: Search in Project… from the Command Palette to start at the workspace folder). The Search in project view opens like TIA Portal's: enter the text, check or change the folder in Search in, and press Start search.

  • What is searched: Openness XML, .db, .udt, .scl, .awl, .stl and .s7dcl (with the titles and comments of its .s7res) below the folder: block and type names, the author of data blocks, titles and comments, interface members (name, data type, start value), program code line by line, and the operands and called blocks of LAD networks. In PLC tag tables (Openness XML) it searches the name, data type, address and comment of every tag and the name, data type, value and comment of every constant. Types are not expanded, so the members of a UDT are found in the UDT, not in every block that uses it, and start values that are only the type's default are not matched.
  • Find exact match only finds whole words: Motor1 does not find Motor10. The search ignores case.
  • Result: one row per block, data block or type with its number of matches; expand it to see each match with its location in the Path column, for example \Interface\Input\Ib_Start\Name or \Network 3\Program code\Line 12. Results appear while the search runs, and Stop ends it.
  • Limit search to (left): as in TIA Portal every entry is a search area, and ticking or unticking changes the result without searching again. A kind of block (OB, FB, FC, DB, PLC data types) takes in everything in it, including its name; a property (name, author, comment, interface, program code) takes in that part of every block, and Tags and Constants take in those of the PLC tag tables. To see only the PLC data types, leave just PLC data types ticked.
  • Open: double-click a row (or press Enter) to open the file in the TIA Viewer; hold Ctrl and double-click (Ctrl+Enter) to open its source text at the first match.
  • Limits: a block shows its first 500 matches (marked 500+), the search stops after 5000 blocks, and folders such as .git and node_modules are skipped.

git diff

Open a change of an exported file (*.db, *.udt, *.s7dcl, *.scl, *.awl, *.stl, *.xml) from Source Control or the Timeline: both versions are shown in the TIA Viewer side by side, differences are marked red (old version) and green (new version), and both sides scroll together.

Required

  • A Git repository that contains the exported files, and the built-in Git extension of VS Code.

Optional

  • A .gitattributes file in the repository. TIA Portal writes Windows line endings; pinning them keeps line-ending changes out of the diffs. It is the only setup that was needed in testing:

    # TIA Portal exports: stable line endings, so a diff shows real changes only
    *.db   text eol=crlf
    *.udt  text eol=crlf
    *.s7dcl text eol=crlf
    *.s7res text eol=crlf
    *.scl  text eol=crlf
    *.awl  text eol=crlf
    *.stl  text eol=crlf
    *.xml  text eol=crlf
    

    Apply it to files that are already committed with git add --renormalize ..

  • workbench.editorAssociations, only if a change opens as a plain text diff instead of two viewers. It makes the viewer the default editor for these file types (user or workspace settings.json):

    "workbench.editorAssociations": {
      "*.db": "tia.viewer",
      "*.udt": "tia.viewer",
      "*.s7dcl": "tia.viewer",
      "*.s7res": "tia.viewer",
      "*.scl": "tia.viewer",
      "*.awl": "tia.viewer",
      "*.stl": "tia.viewer",
      "*.xml": "tia.viewer"
    }
    

    Use Reopen Editor With… > Text Editor to see the plain text diff of a single file again.

The viewer compares a git: revision with the file on disk. Staged changes (index vs. HEAD) are shown unmarked, and the scroll position is synchronised in pixels, so the sides drift apart when earlier content differs in height.

Development

npm run build bundles the extension (src/ → dist/), npm test runs the unit tests in tests/ (fixtures in fixtures/; every XML under the git-ignored test/Project is additionally parsed and laid out when present), npm run typecheck runs tsc. Press F5 to start an Extension Development Host.

The grammars are in syntaxes/. scripts/tokenize.js tokenizes sample files with them and lists every token that has no scope, plus how often each scope occurs:

npm install
npm run tokenize -- --dir <samples> --ext <scl|awl|db|udt> [--strict] [--top 25]
  • --dir defaults to test/, which is git-ignored and holds local samples.
  • --strict exits with code 1 if any token has no scope.

Resources

Export Formats

  • Overview of Export Formats

AWL/STL – Statement List

  • STL programming language
  • STL S7-1500
  • Creating STL Programs

SCL – Structured Control Language

  • SCL Programming Language
  • SCL S7-1200 / S7-1500 / S7-1200 G2
  • Creating SCL Programs

UDT – User-Defined Type

  • Declaring PLC Data Types (UDT)

DB – Data Block

  • Basic Principles for Programming of Data Blocks

SD Format

  • Exporting and Importing Blocks in Simatic SD Format

FBD – Function Block Diagram

  • Creating FBD Programs

F-DB – Fail-safe Data Block

  • Differences between the F-FBD and F-LAD programming languages and the standard FBD and LAD programming languages

Technology Objects

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