YANG
termKept in this browser · My desk
The data modelling language of RFC (Request for Comments) 7950, used to model configuration data, state data, remote procedure calls and notifications for network management protocols.
A YANG module defines the tree that NETCONF (Network Configuration Protocol) and RESTCONF read and change: containers, lists keyed by a leaf, and typed leaves. The ietf-interfaces module of RFC (Request for Comments) 8343 is the usual first example; encoded in JSON (JavaScript Object Notation) under RFC 7951, its data carries the module name in front, as in ietf-interfaces:interfaces, so a program knows exactly which model a value belongs to.
YANG is a schema language, not a protocol and not an encoding. A module is a text file that describes data as a tree in which every node has a name and either a value or a set of child nodes, together with the types, constraints and operations that go with it. What travels on the wire is something else: the same model is carried as XML (Extensible Markup Language) by NETCONF (Network Configuration Protocol) and as XML or JSON (JavaScript Object Notation) by RESTCONF, and the specification notes that other protocols and encodings are possible. Module files are named after the module, optionally followed by an at sign and a revision date, with the extension .yang; an equivalent XML notation called YIN (YANG Independent Notation) exists for tools and loses nothing in translation.
The language answers a complaint operators made in public. An IAB (Internet Architecture Board) workshop held from 4 to 6 June 2002 in Reston, Virginia, recorded in RFC (Request for Comments) 3535, found that SNMP (Simple Network Management Protocol) worked reasonably well for monitoring but that equipment was usually not fully configurable through it, and listed what operators wanted instead: a clear distinction between configuration data, operational state and statistics, the ability to fetch each separately, configuration transactions across devices, and a way to dump and restore a configuration. NETCONF, now RFC 6241, supplied the protocol. YANG supplied the description of the content: version 1 is RFC 6020 of October 2010, edited by Martin Bjorklund, and version 1.1 is RFC 7950 of August 2016, a maintenance release with a small number of backward incompatibilities that expressly does not obsolete RFC 6020, so both versions remain valid and a 1.1 module must say so with a yang-version statement. Both are Proposed Standards; RFC 7950 has been updated by RFC 8342 and RFC 8526, and RFC 6020 by RFC 9890 (October 2025), which revised how IANA (Internet Assigned Numbers Authority) keeps module names unique.
Four kinds of data node do most of the work. A leaf holds one value of one type and has no children; a leaf-list is a sequence of such values; a container groups other nodes; a list is a sequence of entries, each identified by the value of its key leaf or leaves. A container is by default only structure, and can be declared a presence container when its mere existence carries meaning. The config statement marks a subtree as configuration (true) or state (false), which is the distinction the operators asked for in 2002. There are 19 built-in types, among them the signed and unsigned integers from 8 to 64 bits, decimal64, string, boolean, enumeration, bits, binary, empty, union and three kinds of reference: leafref, which points at another leaf, identityref and instance-identifier. A typedef derives a new type by restricting a base type with a range or a pattern, and the common derived types (addresses, counters, dates) are published as modules of their own, since December 2025 in RFC 9911, which obsoleted RFC 6991. Constraints between nodes are written with must and when statements in XPath (XML Path Language) 1.0. Operations are modelled as well: rpc for a procedure on the whole device, action, added in version 1.1, for one tied to a container or list entry, and notification for events.
Modules are built to be extended and to be honest. Each has a namespace, a prefix and dated revision statements; it can import other modules and reuse definitions through grouping and uses. An augment statement lets one module add nodes to the tree of another, which is how a vendor attaches its own leaves to a standard model. A feature marks part of a model as optional. A deviation statement declares where a server does not implement a module faithfully, and the specification says deviations must never be part of a published standard: they exist so that a client can learn how a particular implementation differs. The YANG Library of RFC 8525 (March 2019) completes the picture by having the server list the modules, datastores and schemas it actually uses.
Nobody reads a long module from top to bottom; engineers read its tree diagram, a notation fixed by RFC 8340 (March 2018). Each line shows a node with flags and markers: rw for configuration, ro for state, -x for an rpc or action, -n for a notification, a question mark for an optional node, an asterisk for a list or leaf-list, the keys of a list in square brackets and an exclamation mark for a presence container. The ietf-interfaces module of RFC 8343 reads, in that notation, as a container interfaces holding a list interface keyed by name, with the writable leaves name, description, type and enabled and the read-only oper-status and statistics, whose octet counters are 64 bits wide. pyang, a validator and converter written in Python, prints such trees and checks modules; yanglint, from the libyang toolkit written in C, does the same job.
Encoding rules are where client code goes wrong. In XML, a node belongs to its module's namespace. In JSON, RFC 7951 uses the module name, not the namespace or the prefix: a member name is qualified as module, colon, node at the top level and wherever a child comes from a different module than its parent, and is written bare everywhere else. Values of the 64-bit types int64, uint64 and decimal64 are encoded as JSON strings, because many JSON parsers cannot hold them exactly as numbers, so an interface counter arrives in quotation marks. The empty type is encoded as an array holding a single null. The same precision limit applies inside constraints: XPath 1.0 numbers are double-precision floating point, and RFC 7950 warns that equality comparisons on 64-bit values may yield unexpected results.
Datastores tie the model to a device. The Network Management Datastore Architecture (NMDA) of RFC 8342 (March 2018) names the configuration datastores running, candidate, startup and intended, which share one schema, and a separate operational datastore for the state in use. Before it, models duplicated every tree, one for configuration and one for state; RFC 8343, which obsoleted RFC 7223, deprecates the old interfaces-state subtree for that reason and keeps it only for servers and clients that do not implement NMDA.
Models come from three kinds of author. The IETF (Internet Engineering Task Force) publishes its own in RFCs, under review guidelines that are now RFC 9907 (March 2026). OpenConfig, a group of network operators, maintains vendor-neutral models written in YANG, and its gNMI (gRPC Network Management Interface) protocol is specified on the assumption that it carries data instances of those schemas. Vendors publish native modules for whatever the first two do not cover; the YangModels repository on GitHub collects the modules of the IETF, of other standards bodies and of vendors in one place. F5 documents that the RESTCONF and NETCONF interface of F5OS is based on OpenConfig models extended with F5-specific namespaces, which is why its paths mix openconfig and f5 prefixes.
The practical difficulties follow from that plurality. The same interface or route can exist in an IETF model, an OpenConfig model and a native one, each with different paths and types, and a device may implement any subset of them with features disabled and deviations applied; the list the device itself reports is the only reliable inventory. A client built against one revision of a module can meet another on the device. And a model is not a behaviour: YANG says what the data looks like and what values are legal, while what the device does on a change is decided by the protocol operation and by the implementation.
Also known as: rfc 7950, yang 1.1, yang module, yang data model
Sources
- IETF, RFC 7950, The YANG 1.1 Data Modeling Language, M. Bjorklund (ed.), August 2016 (read 2026-11-12): a data modelling language used to model configuration data, state data, Remote Procedure Calls and notifications for network management protocols; a maintenance release that does not obsolete RFC 6020; modules and submodules, the four data node types, config true and false, the 19 built-in types, typedef, grouping, augment, feature, deviation, rpc, action and notification; XPath 1.0 for constraints and its double-precision numbers; the file name form and the YIN syntax
- IETF, RFC 7951, JSON Encoding of Data Modeled with YANG, L. Lhotka, August 2016 (read 2026-11-12): namespace-qualified member names formed with the module name, required at the top level and wherever the namespace changes; int64, uint64 and decimal64 encoded as JSON strings; the empty type encoded as [null]
- IETF, RFC 6020, YANG: A Data Modeling Language for the Network Configuration Protocol (NETCONF), M. Bjorklund (ed.), October 2010 (read 2026-11-12): YANG version 1, defined for NETCONF configuration and state data, remote procedure calls and notifications
- RFC Editor, information pages for RFC 7950, RFC 6020 and RFC 6991 (read 2026-11-12): RFC 7950 is a Proposed Standard updated by RFC 8342 and RFC 8526; RFC 6020 is a Proposed Standard updated by RFC 9890; RFC 6991 is obsoleted by RFC 9911
- IAB, RFC 3535, Overview of the 2002 IAB Network Management Workshop, J. Schoenwaelder, May 2003 (read 2026-11-12): the workshop of 4 to 6 June 2002 in Reston, Virginia; SNMP works reasonably well for monitoring, but equipment is usually not fully configurable through it; operators require a clear distinction between configuration data, operational state and statistics, configuration transactions and a way to dump and restore configurations
- IETF, RFC 6241, Network Configuration Protocol (NETCONF), June 2011 (read 2026-11-12): obsoletes RFC 4741
- IETF, RFC 8340 (BCP 215), YANG Tree Diagrams, M. Bjorklund and L. Berger, March 2018 (read 2026-11-12): the node line with status, flags (rw, ro, -x, -n), name, options (? optional, ! presence container, * list or leaf-list, keys in square brackets) and type
- IETF, RFC 8342, Network Management Datastore Architecture (NMDA), March 2018, updates RFC 7950 (read 2026-11-12): the running, candidate, startup and intended configuration datastores, which share a schema, and the operational state datastore
- IETF, RFC 8343, A YANG Data Model for Interface Management, March 2018, obsoletes RFC 7223 (read 2026-11-12): the ietf-interfaces tree (interfaces, the interface list keyed by name, type as an identityref, enabled, oper-status, statistics with 64-bit counters); the interfaces-state subtree is deprecated
- IETF, RFC 8525, YANG Library, March 2019, obsoletes RFC 7895 (read 2026-11-12): a server reports the YANG modules, datastores and datastore schemas it uses
- IETF, RFC 9911, Common YANG Data Types, J. Schönwälder (ed.), December 2025 (read 2026-11-12): a collection of common data types for YANG; obsoletes RFC 6991
- IETF, RFC 9890, An Update to YANG Module Names Registration, October 2025, updates RFC 6020 (read 2026-11-12): amends the IANA guidance on the uniqueness of YANG module and submodule names
- IETF, RFC 9907 (BCP 216), Guidelines for Authors and Reviewers of Documents Containing YANG Data Models, March 2026 (read 2026-11-12): obsoletes RFC 8407
- pyang, README (read 2026-11-12): a YANG validator, transformator and code generator written in Python; YANG is developed by the IETF NETMOD working group
- CESNET, libyang README (read 2026-11-12): a YANG data modelling language parser and toolkit written in C, with the yanglint tool
- OpenConfig, public repository README (read 2026-11-12): a collaborative effort by network operators; a consistent set of vendor-neutral data models written in YANG, based on operational needs
- OpenConfig, gRPC Network Management Interface (gNMI) specification, version 0.10.0, 25 May 2023 (read 2026-11-12): the service is assumed to carry payloads that contain data instances of OpenConfig YANG schemas
- YangModels/yang repository, README (read 2026-11-12): a collection of IETF, IEEE, ETSI, MEF, Broadband Forum and vendor-specific YANG modules
- F5, F5OS-A/F5 rSeries API page, CloudDocs (read 2026-11-12): the F5OS RESTCONF/NETCONF programmability interface is based on standard OpenConfig YANG data models, extended with F5-specific namespaces