Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

ncalc

> 后端框架
Open source

NCalc is a fast and lightweight expression evaluator library for .NET, designed for flexibility and high performance. It supports a wide range of mathematical a

1.1K stars0 likes0 views
WebsiteGitHub

About

NCalc is a fast and lightweight expression evaluator library for .NET, designed for flexibility and high performance. It supports a wide range of mathematical a

NCalc

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.

Want to try it first? Open the NCalc playground and run expressions directly in your browser powered by Blazor WASM.

Documentation

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

Useful entry points:

  • Language reference
  • Evaluation options
  • Runtime features
  • Extensibility and plugins

Install

Use NCalc for the expression engine:

bash
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:

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

Quick Examples

Evaluate an expression

csharp
using NCalc;

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

Use parameters

csharp
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

csharp
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.

csharp
using NCalc.LambdaCompilation;

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

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

  • How to execute mathematical expressions in a string in .NET
  • State of the Art Expression Evaluation

Related Projects

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.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#antlrantlr4asynccsharp

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架