Understand the digital twins model parser

The Digital Twins Definition Language (DTDL) is described in the DTDL Specification. Users can use the Digital Twins Model Parser NuGet package to validate and query a DTDL model. The DTDL model may be defined in multiple files.

Install the DTDL model parser

The parser is available in NuGet.org with the ID: DTDLParser. To install the parser, use any compatible NuGet package manager such as the one in Visual Studio or in the dotnet CLI.

dotnet add package DTDLParser


At the time of writing, the parser version is 1.0.52.

Use the parser to validate and inspect a model

The DTDLParser is a library that you can use to:

  • Determine whether one or more models are valid according to the language v2 or v3 specifications.
  • Identify specific modeling errors.
  • Inspect model contents.

A model can be composed of one or more interfaces described in JSON files. You can use the parser to load all the files that define a model and then validate all the files as a whole, including any references between the files.

The DTDLParser for .NET repository includes the following samples that illustrate the use of the parser:

  • DTDLParserResolveSample shows how to parse an interface with external references, resolve the dependencies using the Azure.IoT.ModelsRepository client.
  • DTDLParserJSInteropSample shows how to use the DTDL Parser from JavaScript running in the browser, using .NET JSInterop.

The DTDLParser for .NET repository also includes a collection of tutorials that show you how to use the parser to validate and inspect models.

Next steps

The model parser API reviewed in this article enables many scenarios to automate or validate tasks that depend on DTDL models. For example, you could dynamically build a UI from the information in the model.