
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
@neuralsea/subnet-tree-calculator
Advanced tools
Themeable React + TypeScript subnet calculator (IPv4 + IPv6) rendered as an interactive SVG binary tree using D3.
A comprehensive React + TypeScript subnet calculator and network design tool (IPv4 + IPv6) with visual binary tree representation, VLSM planning, and extensive automation capabilities.
192.168.0.0/255.255.255.0)npm install subnet-tree-calculator d3
React 19 is a peer dependency.
import { SubnetTreeCalculator } from "subnet-tree-calculator";
import "subnet-tree-calculator/style.css";
export default function App() {
return (
<div style={{ padding: 16 }}>
<SubnetTreeCalculator initialCidr="10.0.0.0/16" initialMaxDepth={8} />
</div>
);
}
<SubnetTreeCalculator initialCidr="2001:db8:abcd::/48" initialMaxDepth={16} />
import { SubnetService } from "subnet-tree-calculator";
const service = new SubnetService();
// Parse CIDR
const cidr = service.parse("10.0.0.0/24");
// Get subnet metadata
const meta = service.getMetadata(cidr);
console.log(meta.usableCount); // 254n
// Split subnet
const [left, right] = service.splitBinary(cidr);
// VLSM allocation
const parent = service.parse("10.0.0.0/16");
const requirements = [
{ name: "Office", hostCount: 500 },
{ name: "DMZ", hostCount: 100 },
{ name: "Management", hostCount: 50 }
];
const allocation = service.allocateVlsm(parent, requirements, "largest-first");
// Export to various formats
import { exportToJson, exportToCsv, exportToMarkdown } from "subnet-tree-calculator";
const subnets = [cidr];
const json = exportToJson(subnets);
const csv = exportToCsv(subnets);
const md = exportToMarkdown(subnets);
# Install globally
npm install -g subnet-tree-calculator
# Parse CIDR
subnet-calc parse 10.0.0.0/24
# Get metadata
subnet-calc meta 192.168.1.0/24
# Split subnet
subnet-calc split 10.0.0.0/16
# VLSM allocation
subnet-calc vlsm 10.0.0.0/16 500,100,50
# Export to various formats
subnet-calc export json 10.0.0.0/24
subnet-calc export csv 10.0.0.0/24
subnet-calc export md 10.0.0.0/24
subnet-calc export tf 10.0.0.0/24
import { exportToSvg, downloadSvg, exportToPng, downloadPng } from "subnet-tree-calculator";
// Get SVG element from the tree
const svgElement = document.querySelector('svg');
// Export to SVG string
const svgString = exportToSvg(svgElement);
// Download SVG file
downloadSvg(svgElement, 'subnet-tree.svg');
// Export to PNG blob
const pngBlob = await exportToPng(svgElement, { width: 1920, height: 1080, scale: 2 });
// Download PNG file
await downloadPng(svgElement, 'subnet-tree.png', { width: 1920, height: 1080 });
npm run dev
npm run test:run # Run all tests
npm run test:watch # Watch mode
npm run test:ui # UI mode
npm run storybook # Development mode
npm run storybook:build # Build static site
npm run storybook:test # Run interaction tests
npm run lint # TypeScript type checking
npm run typecheck # Type checking only
npm run verify # Run all checks (lint + tests + storybook build)
The project follows Hexagonal (Ports & Adapters) Architecture:
Core Domain (src/core/): Pure TypeScript logic with no UI dependencies
parser.ts: CIDR parsing and formattingcalculations.ts: Subnet metadata calculationstransformations.ts: Split, merge, summarize operationsset-operations.ts: Containment, overlap, union/intersection/differencevlsm.ts: VLSM allocation strategiesexport.ts: Export to various formatssearch.ts: Search and filter functionalitychanges.ts: Change tracking and diffingnotes.ts: Notes and referenceswarnings.ts: Edge case warningsvisual-export.ts: SVG/PNG/PDF export functionalityservice.ts: Facade over all domain capabilitiesCLI Layer (src/cli.ts): Command-line interface for automation
UI Layer (src/): React components
SubnetTreeCalculator.tsx: Main visual designer componentTests (src/**/*.test.ts): Comprehensive unit tests
The component supports light and dark themes via CSS custom properties:
<SubnetTreeCalculator
initialCidr="10.0.0.0/16"
theme={{
background: "#1e1e1e",
text: "#ffffff",
nodeFill: "#2d2d2d",
nodeStroke: "#4a9eff",
linkStroke: "#666666"
}}
/>
Or use CSS variables:
:root {
--subnet-bg: #ffffff;
--subnet-text: #000000;
--subnet-node-fill: #f0f0f0;
--subnet-node-stroke: #0066cc;
--subnet-link-stroke: #999999;
}
All core domain logic is thoroughly tested:
parser.test.ts: 21 testscalculations.test.ts: 19 teststransformations.test.ts: 20 testsset-operations.test.ts: 21 testsvlsm.test.ts: 12 testsexport.test.ts: 11 testsservice.test.ts: 26 testssearch.test.ts: 21 testschanges.test.ts: 11 testsnotes.test.ts: 14 testswarnings.test.ts: 17 testscli.test.ts: 17 testsvisual-export.test.ts: 7 testsintegration.test.ts: 6 testsSubnetTreeCalculator.layout.test.tsx: 3 testsSee TRACEABILITY.json for complete mapping of functional requirements to implementation and tests.
Status: All 53 FRs and 43 UCs complete (100%)
MIT
Contributions are welcome! Please ensure:
npm run test:run)npm run typecheck)npm run storybook:build)FAQs
Themeable React + TypeScript subnet calculator (IPv4 + IPv6) rendered as an interactive SVG binary tree using D3.
We found that @neuralsea/subnet-tree-calculator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.