YANG – Data Modeling Language

What is a Data Model?

A data model is a description of how data must be encoded for information exchange between two entities.

What is YANG?

YANG is a text-based data modeling language designed for use with any network management protocol including NETCONF and RESTCONF. YANG is used to model [semantics and constraints of] configuration and operational state data as well as general RPC data.

YANG Relationship to XML and JSON

YANG used to represent the data on a device in an abstract way but does not contain actual device configuration or operational data; it simply shows the structure. In other words, YANG forms the template from which XML/JSON data is generated and does not represent the actual data.

Yang modules

YANG data models are composed of modules [YANG files]. Each module defines a single data model and is uniquely identified by a namespace URI. Module can “include”, “import” and “augment” other modules and submodules.

Yang Hierarchy  

YANG models the hierarchical organization of data as a tree in which each node has a name and a value or a set of child nodes. There are four nodes types. The nodes types are:

  • Container: A grouping of other nodes (has no “Value”)
  • List: Multiple records containing at least one Leaf “Key” and an arbitrary hierarchy of other statements
  • Leaf: Single key/value pair and has no children.
  • Leaf-list: Multiple key/values pair of the same type

Leaf and leaf-list nodes includes the “type” statement to identify the data type for valid data for that node. YANG defines a set of built-in types and provides the “typedef” statement for defining a derived type from a base type, which can be either a built-in type or another derived type.

YANG Data Model

container vlans {
  list vlan {
    key "id";
    leaf id {
      type int;
      range 1..4094;
    leaf name {
      type string;

XML Encoded Data


JSON Encoded Data

  "vlans": {
    "vlan": [
      "id": "100",
      "name": "web_vlan"
      "id": "200",
      "name": "app_vlan"




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.