Moka.Blazor.Json
0.1.4
See the version list below for details.
dotnet add package Moka.Blazor.Json --version 0.1.4
NuGet\Install-Package Moka.Blazor.Json -Version 0.1.4
<PackageReference Include="Moka.Blazor.Json" Version="0.1.4" />
<PackageVersion Include="Moka.Blazor.Json" Version="0.1.4" />
<PackageReference Include="Moka.Blazor.Json" />
paket add Moka.Blazor.Json --version 0.1.4
#r "nuget: Moka.Blazor.Json, 0.1.4"
#:package Moka.Blazor.Json@0.1.4
#addin nuget:?package=Moka.Blazor.Json&version=0.1.4
#tool nuget:?package=Moka.Blazor.Json&version=0.1.4
<p align="center"> <img src="icon.png" alt="Moka.Blazor.Json" width="128" /> </p>
<h1 align="center">Moka.Blazor.Json</h1>
<p align="center"> A high-performance Blazor JSON viewer and editor component with virtualized rendering, search, theming, and plugin support. </p>
<p align="center"> <a href="https://www.nuget.org/packages/Moka.Blazor.Json"><img src="https://img.shields.io/nuget/v/Moka.Blazor.Json.svg" alt="NuGet" /></a> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a> </p>
Features
- Virtualized rendering - handles documents up to 100 MB with smooth scrolling
- Search - plain text, regex, case-sensitive with match navigation
- Theming - light, dark, auto (system preference), or fully custom via CSS variables
- Context menu - built-in actions + extensible custom actions with type/property filtering
- Breadcrumb navigation - clickable path segments for easy traversal
- Streaming parsing - incremental parsing for large documents via
JsonStream - Key sorting - sort object keys alphabetically (single level or recursive)
- Node scoping - zoom into any subtree
- Zero external dependencies - built on
System.Text.Json - Multi-target - supports .NET 8, .NET 9, and .NET 10
Installation
dotnet add package Moka.Blazor.Json
Quick Start
1. Register services
// Program.cs
builder.Services.AddMokaJsonViewer();
2. Add the component
@using Moka.Blazor.Json.Components
<MokaJsonViewer Json="@myJson" />
@code {
private string myJson = """{"name":"Alice","age":30,"tags":["dev","admin"]}""";
}
3. Two-way binding
<MokaJsonViewer @bind-Json="myJson" />
@code {
private string myJson = """{"name":"Alice"}""";
// myJson updates automatically when the document is modified
}
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
Json |
string? |
null |
JSON string to display |
JsonStream |
Stream? |
null |
Stream for incremental parsing (mutually exclusive with Json) |
Theme |
MokaJsonTheme |
Auto |
Auto, Light, Dark, or Inherit |
ShowToolbar |
bool |
true |
Show the toolbar |
ShowBottomBar |
bool |
true |
Show the status bar |
ShowBreadcrumb |
bool |
true |
Show the breadcrumb path |
ShowLineNumbers |
bool |
false |
Show line numbers |
ReadOnly |
bool |
true |
Disable editing |
MaxDepthExpanded |
int |
2 |
Initial expansion depth |
Height |
string |
"400px" |
Component height |
OnNodeSelected |
EventCallback<JsonNodeSelectedEventArgs> |
Fires when a node is clicked | |
OnJsonChanged |
EventCallback<JsonChangeEventArgs> |
Fires when JSON is modified (detailed) | |
JsonChanged |
EventCallback<string?> |
Two-way binding callback for @bind-Json |
|
OnError |
EventCallback<JsonErrorEventArgs> |
Fires on parse/runtime errors | |
ContextMenuActions |
IReadOnlyList<MokaJsonContextAction>? |
null |
Custom context menu actions |
ToolbarExtra |
RenderFragment? |
null |
Extra toolbar content |
Configuration
builder.Services.AddMokaJsonViewer(options =>
{
options.DefaultTheme = MokaJsonTheme.Dark;
options.DefaultExpandDepth = 3;
options.MaxDocumentSizeBytes = 200 * 1024 * 1024; // 200 MB
options.SearchDebounceMs = 300;
options.StreamingThresholdBytes = 2 * 1024 * 1024; // 2 MB
options.MaxClipboardSizeBytes = 100 * 1024 * 1024; // 100 MB
});
Programmatic Control
The component implements IMokaJsonViewer for programmatic access:
<MokaJsonViewer @ref="_viewer" Json="@json" />
@code {
private MokaJsonViewer _viewer = null!;
private async Task NavigateToUser()
{
await _viewer.NavigateToAsync("/users/0/name");
}
private async Task Search()
{
var matchCount = await _viewer.SearchAsync("error", new JsonSearchOptions
{
CaseSensitive = false,
UseRegex = true,
SearchKeys = true,
SearchValues = true
});
}
}
Available methods:
NavigateToAsync(jsonPointer)- Navigate to a JSON Pointer pathExpandToDepth(depth)- Expand nodes to depth (-1 for all)ExpandAll()/CollapseAll()- Expand or collapse the entire treeSearchAsync(query, options)- Search with optional regex/case sensitivityNextMatch()/PreviousMatch()- Navigate search resultsClearSearch()- Clear search stateGetJson(indented)- Get the current JSON as a string
Custom Context Menu Actions
Add type-aware context menu actions:
private readonly List<MokaJsonContextAction> _actions =
[
new MokaJsonContextAction
{
Id = "open-url",
Label = "Open URL",
ShortcutHint = "Enter",
Order = 500,
HasSeparatorBefore = true,
IsVisible = ctx => ctx.ValueKind == JsonValueKind.String
&& ctx.RawValuePreview.StartsWith("\"http", StringComparison.OrdinalIgnoreCase),
OnExecute = ctx =>
{
var url = ctx.RawValuePreview.Trim('"');
// Open URL...
return ValueTask.CompletedTask;
}
},
new MokaJsonContextAction
{
Id = "format-currency",
Label = "Format as Currency",
Order = 510,
IsVisible = ctx => ctx.ValueKind == JsonValueKind.Number
&& ctx.PropertyName is "salary" or "price" or "amount",
OnExecute = ctx =>
{
// Format number as currency...
return ValueTask.CompletedTask;
}
}
];
<MokaJsonViewer Json="@json" ContextMenuActions="_actions" />
Theming
Built-in themes
<MokaJsonViewer Json="@json" Theme="MokaJsonTheme.Dark" />
Custom CSS variables
Override any of these CSS custom properties:
.my-custom-theme {
/* Syntax highlighting */
--moka-json-color-key: #0451a5;
--moka-json-color-string: #a31515;
--moka-json-color-number: #098658;
--moka-json-color-boolean: #0000ff;
--moka-json-color-null: #808080;
--moka-json-color-bracket: #319331;
/* UI */
--moka-json-bg: transparent;
--moka-json-color-text: #1e1e1e;
--moka-json-color-border: #e0e0e0;
--moka-json-color-hover: rgba(0, 0, 0, 0.04);
--moka-json-color-selected: rgba(0, 120, 212, 0.1);
--moka-json-toolbar-bg: #f3f3f3;
--moka-json-context-bg: #ffffff;
/* Search highlighting */
--moka-json-color-search-match: rgba(234, 192, 0, 0.4);
--moka-json-color-search-active: rgba(234, 128, 0, 0.6);
/* Typography */
--moka-json-font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
--moka-json-font-size: 13px;
--moka-json-line-height: 1.6;
}
Use Theme="MokaJsonTheme.Inherit" to apply your own theme class without any built-in overrides.
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+F |
Toggle search |
F3 / Enter |
Next match |
Shift+F3 |
Previous match |
Esc |
Close search |
Ctrl+Z |
Undo (edit mode) |
Ctrl+Y |
Redo (edit mode) |
Event Callbacks
<MokaJsonViewer Json="@json"
OnNodeSelected="HandleNodeSelected"
OnError="HandleError" />
@code {
private void HandleNodeSelected(JsonNodeSelectedEventArgs e)
{
Console.WriteLine($"Selected: {e.Path} ({e.ValueKind})");
Console.WriteLine($"Property: {e.PropertyName}");
Console.WriteLine($"Preview: {e.RawValuePreview}");
}
private void HandleError(JsonErrorEventArgs e)
{
Console.WriteLine($"Error at line {e.LineNumber}: {e.Message}");
}
}
Streaming Large Documents
For documents too large to hold in a string, use JsonStream:
<MokaJsonViewer JsonStream="@_stream" />
@code {
private Stream? _stream;
private async Task LoadLargeFile()
{
_stream = File.OpenRead("large-data.json");
}
}
Project Structure
src/
Moka.Blazor.Json/ # Main component library
Moka.Blazor.Json.Abstractions/ # Interfaces and models
tests/
Moka.Blazor.Json.Tests/ # Unit + bUnit component tests
Moka.Blazor.Json.Benchmarks/ # Performance benchmarks
samples/
Moka.Blazor.Json.Demo/ # Interactive demo application
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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 is compatible. 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. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.5)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options (>= 10.0.5)
- Moka.Blazor.Json.Abstractions (>= 0.1.4)
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.14)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.14)
- Microsoft.Extensions.Options (>= 9.0.14)
- Moka.Blazor.Json.Abstractions (>= 0.1.4)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Moka.Blazor.Json:
| Package | Downloads |
|---|---|
|
Moka.Blazor.Json.Diagnostics
Diagnostic overlay for Moka.Blazor.Json lazy parsing mode. Shows real-time stats on bytes loaded, subtree parses, and cache performance. |
|
|
Moka.Blazor.Json.AI
AI assistant plugin for Moka.Blazor.Json — query, transform, analyze, and summarize JSON using local LLMs via Ollama or any IChatClient provider. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.5.1 | 129 | 4/2/2026 |
| 0.5.0 | 125 | 4/2/2026 |
| 0.4.4 | 115 | 4/2/2026 |
| 0.4.3 | 120 | 4/2/2026 |
| 0.4.2 | 117 | 3/31/2026 |
| 0.4.1 | 115 | 3/31/2026 |
| 0.4.0 | 130 | 3/27/2026 |
| 0.3.0 | 105 | 3/26/2026 |
| 0.2.0 | 103 | 3/26/2026 |
| 0.1.10 | 97 | 3/17/2026 |
| 0.1.9 | 101 | 3/17/2026 |
| 0.1.8 | 101 | 3/16/2026 |
| 0.1.7 | 102 | 3/16/2026 |
| 0.1.6 | 95 | 3/16/2026 |
| 0.1.5 | 94 | 3/15/2026 |
| 0.1.4 | 96 | 3/15/2026 |
| 0.1.3 | 90 | 3/15/2026 |
| 0.1.2 | 94 | 3/14/2026 |
| 0.1.1 | 101 | 3/14/2026 |
| 0.1.0 | 94 | 3/14/2026 |