NCalcSync 6.3.1

NCalc

GitHub Actions Workflow Status Coverage NuGet NuGet Downloads Discord

NCalc is a fast, lightweight expression evaluator for .NET. It parses and evaluates mathematical and logical expressions with literals, operators, parameters, built-in functions, and custom functions.

NCalc targets modern .NET, .NET Standard 2.0, and .NET Framework 4.8.

Documentation

Start with the NCalc docs for the full language reference, runtime options, plugins, and API reference.

Useful entry points:

Install

Use NCalc for the expression engine:

dotnet add package NCalc

[!IMPORTANT] NCalc, NCalcSync, and NCalcAsync are redirect packages that currently point directly to NCalc.Core, preserving compatibility from before the community efforts were consolidated into the same repository.

Add optional packages only when you need them:

dotnet add package NCalc.LambdaCompilation
dotnet add package NCalc.DependencyInjection

Quick Examples

Evaluate an expression

using NCalc;

var result = new Expression("2 + 3 * 5").Evaluate();
// 17

Use parameters

var expression = new Expression("Round(Pow([x], 2) + [offset], 2)");
expression.Parameters["x"] = 3.14;
expression.Parameters["offset"] = 10;

var result = expression.Evaluate();
// 19.86

Add custom functions

var expression = new Expression("SecretOperation(3, 6)");
expression.Functions["SecretOperation"] = args =>
    (int)args.Evaluate(0) + (int)args.Evaluate(1);

var result = expression.Evaluate();
// 9

Compile to a lambda

Install NCalc.LambdaCompilation first.

using NCalc.LambdaCompilation;

var expression = new Expression("1 + 2");
Func<int> function = expression.ToLambda<int>();

var result = function();
// 3

For data types, operators, built-in functions, async evaluation, caching, expression serialization, and advanced configuration, check the docs.

Help

Open an issue for bugs or usage problems. Include the expression, the expected result, the actual result, and your NCalc version.

Learn More

Project Description
FastExpressionCompiler Fast compiler for C# expression trees. NCalc uses it for lambda compilation.
Jint JavaScript interpreter for .NET by Sebastien Ros, the original author of NCalc.
JJMasterData Runtime form generator that uses NCalc for field visibility and other dynamic behavior.
NCalc101 Web application for trying NCalc expressions, developed by Panoramic Data.
NCalcJS TypeScript/JavaScript port of NCalc.
PanoramicData.NCalcExtensions Extension functions for NCalc, including string functions, switch, if, in, typeOf, and cast.
Parlot Fast and lightweight parser creation tools by Sebastien Ros. NCalc uses Parlot in its default parser.

Using NCalc? Create a PR and add your project here!

Versioning

NCalc uses Nerdbank.GitVersioning. Each library build can be traced back to the original git commit. Read more in the release documentation.

Star History

Star History Chart

Showing the top 20 packages that depend on NCalcSync.

Packages Downloads
JJMasterData.NCalc
JJMasterData NCalc expressions support.
14
JJMasterData.Core
JJMasterData library to render JJMasterData's components.
14
JJMasterData.Core
JJMasterData library to render JJMasterData's components.
13
JJMasterData.Core
JJMasterData library to render JJMasterData's components.
12

.NET 10.0

.NET Framework 4.6.2

.NET 8.0

.NET Standard 2.0

Version Downloads Last updated
6.3.3 0 30.06.2026
6.3.2 0 25.06.2026
6.3.1 1 24.06.2026
6.3.0 1 24.06.2026
6.2.0 1 24.06.2026
6.1.1 1 14.06.2026
6.1.0 1 14.06.2026
6.0.0 1 14.06.2026
5.13.0 1 14.06.2026
5.12.0 6 21.02.2026
5.11.0 6 10.02.2026
5.10.0 5 18.12.2025
5.9.0 6 18.12.2025
5.8.0 6 09.11.2025
5.7.0 9 24.09.2025
5.6.0 10 08.08.2025
5.5.0 9 08.08.2025
5.5.0-alpha 12 19.03.2025
5.4.2 10 31.05.2025
5.4.1 12 19.03.2025
5.4.0 11 19.03.2025
5.3.1 13 09.01.2025
5.3.0 11 19.03.2025
5.2.11 13 09.01.2025
5.2.10 11 19.03.2025
5.2.9 13 19.03.2025
5.2.8 13 19.03.2025
5.2.7 12 19.03.2025
5.2.6 11 19.03.2025
5.2.5 12 19.03.2025
5.2.4 12 19.03.2025
5.2.3 13 19.03.2025
5.2.2 11 19.03.2025
5.2.1 13 19.03.2025
5.2.0 10 19.03.2025
5.1.0 12 19.03.2025
5.0.0 13 19.03.2025
4.4.0-alpha 12 19.03.2025
4.3.3 12 19.03.2025
4.3.2 12 19.03.2025
4.3.1 12 19.03.2025
4.3.0 14 19.03.2025
4.2.1 11 19.03.2025
4.2.0 10 19.03.2025
4.1.0 11 19.03.2025
4.0.0 13 09.01.2025
3.13.1 14 19.03.2025
3.13.0 12 19.03.2025
3.12.0 13 19.03.2025
3.11.0 11 19.03.2025
3.10.0 13 19.03.2025
3.9.0 12 19.03.2025
3.8.0 11 19.03.2025
3.7.0 11 19.03.2025
3.6.0 12 19.03.2025
3.5.0 12 19.03.2025
3.4.0 11 19.03.2025
3.2.0 12 19.03.2025
3.1.0 14 19.03.2025
3.0.0 12 19.03.2025
2.0.0 12 19.03.2025