Knowledge Base

Open-Sourcing Our Delphi Toolkit: Five Libraries Born from Building AI Applications

Why we’re doing this

At GDK Software, we’ve spent the past six months building Codolex AI, a full-stack web application written entirely in Delphi. Along the way, we kept running into problems that had no good Delphi solution. So we built our own.

These libraries started as internal tools. They solved specific problems we had while shipping a production AI platform. But they turned out to be genuinely useful on their own, and we believe the Delphi community deserves access to them.

Here are all five, now publicly available on GitHub.

JavaScript4D: A complete JavaScript interpreter

LLMs can write Delphi, but they’re far more fluent in JavaScript. When we needed AI-generated code to run inside our Delphi application, asking the model to produce JavaScript and executing it locally turned out to be more reliable than generating Delphi on the fly. We just needed an interpreter that didn’t require Node.js or a browser.

JavaScript4D is a full ECMAScript 5.1 interpreter written in pure Delphi. It follows a classical compiler architecture (lexer, parser, AST, tree-walking interpreter) and supports closures, higher-order functions, try/catch/finally, and 59 built-in methods across Array, String, Math, JSON, and Object.

Engine := TJSEngine.Create;
try
  Engine.Execute('var data = [1, 2, 3, 4, 5];');
  Result := Engine.Evaluate(
    'data.map(function(n) { return n * 2; })' +
    '    .filter(function(n) { return n > 4; })' +
    '    .reduce(function(a, b) { return a + b; }, 0)'
  );
  // Result: 24
finally
  Engine.Free;
end;

Over 11,000 lines of code. No DLLs, no external dependencies. Just add the units to your project.

GitHub: github.com/GDKsoftware/Javascript4D

OfficeXML4D: Read and write Word and Excel files

Users upload .docx and .xlsx files in chat conversations, and the platform needs to read and generate them. We didn’t want to depend on Microsoft Office being installed on our Linux servers.

OfficeXML4D reads and writes Office Open XML documents using only Delphi’s built-in System.Zip and XML units. Word documents with paragraphs, tables, headers, hyperlinks, and formatting. Excel workbooks with multiple sheets, cell styles, formulas, merged cells, and shared string optimization.

Doc := TWordDocumentFactory.CreateDocument;

Para := Doc.AddParagraph;
Run := Para.AddRun('Quarterly Report');
Run.Bold := True;
Run.FontSize := 32; // half-points, so 32 = 16pt

Doc.SaveToFile('report.docx');

135 unit tests. Interface-based API for clean dependency injection.

GitHub: github.com/GDKsoftware/OfficeXML4D

Microsoft365-4D: Graph API integration

Codolex AI connects to Microsoft 365 to read emails, manage calendars, search SharePoint, and work with contacts. We needed a Delphi client that handled OAuth2 with PKCE properly and provided typed responses.

Microsoft365-4D covers mail (search, read, compose, send, attachments, folders), calendar (events, availability), contacts (CRUD), and SharePoint (sites, files, search). It includes a complete OAuth2 PKCE implementation with thread-safe token management.

Http := TGraphHttpClient.Create(AccessToken);
Mail := TMailClient.Create(Http);

Result := Mail.SearchMessages('from:client@example.com', '', 20, 0);
for Msg in Result.Messages do
  WriteLn(Msg.Subject, ' - ', Msg.From.Address);

All clients share a single HTTP connection. Only depends on System.Net.HttpClient.

GitHub: github.com/GDKsoftware/Microsoft365-4D

Toon4D: Spend less on LLM tokens

Every token you send to an LLM costs money and adds latency. When you’re passing structured data like customer records, product catalogs, or API responses, standard JSON wastes tokens on repeated keys and punctuation.

Toon4D converts JSON to TOON (Token-Oriented Object Notation), a compact format that LLMs read just as well. Arrays of objects with identical keys become CSV-style tables. Repeated structure gets folded. The result: 30-60% fewer tokens.

// JSON input (37 tokens):
{"employees":[
  {"id":1,"name":"Alice","role":"admin"},
  {"id":2,"name":"Bob","role":"user"}
]}

// TOON output (15 tokens):
employees[2]{id,name,role}:
1,Alice,admin
2,Bob,user
Options := [TToonOption.PreferTabular];
ToonOutput := TToon.JsonToToon(JsonString, Options);

340+ conformance tests against the TOON v2.0 specification.

GitHub: github.com/GDKsoftware/Toon4D

Delphi MCP Server: Connect AI assistants to Delphi

The Model Context Protocol lets AI assistants like Claude interact with external tools. Our MCP server implementation, which we released earlier this year, provides the protocol framework. It uses RTTI for automatic tool discovery and runs on both Windows and Linux.

GitHub: github.com/GDKsoftware/delphi-mcp-server

What they have in common

All five libraries share a few design principles:

  • Zero external dependencies. They use only Delphi RTL units. No third-party packages to manage, no DLLs to deploy.
  • Interface-based APIs. Clean contracts that make testing and mocking straightforward.
  • Tested in production. These aren’t weekend experiments. They run in Codolex AI, handling real workloads every day.
  • MIT-licensed. Use them however you want. Commercial, open source, anything.
  • Delphi 12 Athens or later (OfficeXML4D works from Delphi 10.3 Rio).

The bigger picture

We built Codolex AI to prove that Delphi is a serious platform for modern applications: web apps, AI integration, cloud deployment, all of it. These libraries are the building blocks that made it possible.

Open-sourcing them is our way of giving back to a community that has given us a lot over the past thirty years. If they save you time or solve a problem you’re facing, that’s a win for everyone.

We’d love to hear what you build with them.

All libraries are available on GDK Software’s GitHub. Questions, issues, or pull requests are welcome.

Written by Marco Geuze
Director

Contact

Let us help you to realise your ambitions