YAMLScript 0.2.7

dotnet add package YAMLScript --version 0.2.7
                    
NuGet\Install-Package YAMLScript -Version 0.2.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="YAMLScript" Version="0.2.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YAMLScript" Version="0.2.7" />
                    
Directory.Packages.props
<PackageReference Include="YAMLScript" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add YAMLScript --version 0.2.7
                    
#r "nuget: YAMLScript, 0.2.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package YAMLScript@0.2.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=YAMLScript&version=0.2.7
                    
Install as a Cake Addin
#tool nuget:?package=YAMLScript&version=0.2.7
                    
Install as a Cake Tool

YAMLScript

Add Logic to Your YAML Files

Quick Start

This library lets you load YAML files that may or may not contain YAMLScript functional programming logic. You can use it as a drop-in replacement for your current YAML loader.

Here's an example config.yaml that makes use of YAMLScript functions.

# config.yaml with YAMLScript:
!ys-0:

# Define variables
db-host =: ENV.DB_HOST || 'localhost'
db-port =: ENV.DB_PORT || 5432
deploy =: ENV.DEPLOYMENT || 'dev'
:when deploy !~ /^(dev|stage|prod)/:
  die: |
    Invalid deployment value '$deploy'.
    Must be one of: dev | stage | prod

# Normal YAML data
description: Dynamic application configuration

# Dynamic data values
database:
  host:: db-host
  port:: db-port:num
  name:: "app_$deploy"

# Import external data
features:: load('common.yaml').features

# Use logic and conditions
cache:
  # Variable scoped to this mapping
  enabled =: deploy == 'production'

  directory: .cache
  enabled:: enabled
  limit: 100
  # Conditional key/value pairs
  :when enabled::
    limit:: 1000
    ttl:: 60 * 60  # 3600

What is YAMLScript?

YAMLScript is a functional programming language that can be embedded in YAML. Its syntax is 100% YAML so files that embed it are still valid YAML files.

The YAMLScript project provides YAML loader libraries for many programming languages. They can be used to load any YAML config files properly, whether or not they contain functional programming logic.

It's perfect for:

  • Configuration files that need logic, variables, and dynamic values
  • Data transformation with built-in functions for JSON, YAML, and text processing
  • Templating with powerful string interpolation and data manipulation
  • Scripting as a complete functional programming language

Key Features

  • Drop-in YAML replacement – Works with your existing YAML files
  • Variables & functions – Define and reuse values throughout your files
  • External data loading – Import JSON, YAML, or data from URLs
  • Conditional logic – Use if/then/else and pattern matching
  • Data transformation – Built-ins for transforming & manipulating data
  • String interpolation – Embed expressions/variables directly in strings
  • No JVM required – Runs as a native library despite compiling to Clojure

How It Works

YAMLScript extends YAML with a simple, elegant syntax:

# file.yaml
!ys-0:               # Enable YAMLScript

name =: 'World'       # Variable assignment
nums =:: [1, 2, 3]    # Any YAML value

# Literal YAML with ':'
a key: a value

# Evaluated expressions with '::'
message:: "Hello, $name!"
sum:: nums.reduce(+)
timestamp:: now():str

You can load this file from a program as described below, or you can use the ys YAMLScript binary to load the file from the command line:

$ ys -Y file.yaml
a key: a value
message: Hello, World!
sum: 6
timestamp: '2025-09-14T22:35:42.832470203Z'

Under the hood, YAMLScript compiles YAML to Clojure and evaluates it, giving you access to a rich functional programming environment.

C# Usage

Use YAMLScript.NET as a drop-in replacement for your current YAML loader:

// Program.cs
using YAMLScript;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        using var ys = new YAMLScriptLoader();

        // Load from file
        string input = File.ReadAllText("config.yaml");
        var config = ys.Load(input);

        Console.WriteLine(config);
    }
}

Installation

Install YAMLScript for .NET and the libys.so shared library:

# Add package reference
dotnet add package YAMLScript.NET

# Install shared library
curl -sSL https://yamlscript.org/install | bash

See https://yamlscript.org/doc/install/ for more info.

Requirements

  • .NET 8.0 or higher

See Also

Authors

YAMLScript C# Binding Authors

Maintainers

Contributors

This file will be updated as contributors add to the C# binding.

Copyright 2022-2025 Ingy döt Net ingy@ingy.net

This project is licensed under the terms of the MIT license. See LICENSE for more details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.7 186 10/20/2025
0.2.6 169 10/20/2025
0.2.5 171 10/20/2025
0.2.4 317 9/16/2025
0.2.3 180 9/9/2025
0.2.2 117 7/18/2025
0.2.1 178 7/10/2025