OPC UA NodeId, namespace index and ExpandedNodeId

The string format of NodeIds (ns=2;s=…), the four identifier types, why the namespace index can change and how ExpandedNodeId solves it.

Structure

A NodeId identifies one node in one server. It has two parts:

  • NamespaceIndex (UInt16) — position of the namespace URI in the server's NamespaceArray;
  • Identifier of one of four types:
PrefixTypeExampleTypical use
i=Numeric (UInt32)i=2258Standard nodes, many PLC servers
s=Strings=Line1.Motor3.SpeedSymbolic tag names (S7-1500, CODESYS, TwinCAT)
g=GUIDg=09087e75-8e5e-499b-954f-f2a9603db28aGenerated, stable identifiers
b=Opaque ByteString (Base64)b=M/RbKBsRVkePCePcx24oRA==Vendor-internal handles

String format

OPC 10000-6 defines the text form:

ns=<namespaceIndex>;<type>=<value>
ns=3;s=Motor1.Speed
i=85                       (namespace 0: the ns= part is omitted)

NodeIds in namespace 0 (http://opcfoundation.org/UA/) use only the identifier form, e.g. i=85 for the Objects folder, i=2258 for the server's current time.

Namespace index vs namespace URI

The index is local to a server and may change when the server is reconfigured, when a project is downloaded again or when the order of namespaces changes. A client that stores ns=4;s=Motor1.Speed permanently can break silently. Robust clients store the namespace URI and resolve the index after connecting by reading Server.NamespaceArray (i=2255).

ExpandedNodeId

ExpandedNodeId adds the information needed outside the server's own index table:

nsu=http://example.com/plant/;s=Motor1.Speed      (namespace URI instead of index)
svr=1;nsu=http://example.com/plant/;s=Motor1.Speed (node in another server, ServerIndex 1)

Reserved characters in URIs are percent-encoded; a ; inside a URI is written as %3B. ServerIndex 0 means the local server.

Why a NodeId does not resolve

  • Copying a NodeId from one PLC project to another: the index differs.
  • Writing ns=2;i=Motor1 — a string identifier needs s=.
  • Adding quotation marks around Siemens tag names: the browse path in TIA uses "DB"."Tag", the NodeId string is usually ns=3;s="DB"."Tag" including the quotes — always copy from a browsing client rather than typing.

Loading the map…

Sources

  1. OPC 10000-3 Part 3: Address Space Model (v1.05) — OPC Foundation
  2. OPC 10000-6 Part 6: Mappings (v1.05) — OPC Foundation

Updated 2026-10-02