npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ngx-json-table

v2.1.4

Published

Show and edit a JSON object using HTML table.

Readme

Angular JSON Table

CI Status npm version codecov

ngx-json-table is a flexible Angular component designed to display and edit JSON objects as HTML tables. The library provides powerful features for data manipulation, including inline adding, editing, and deleting of JSON properties and values.

Demo

Live Demo

Features

  • Display JSON objects and arrays in a structured HTML table
  • Inline add/edit/delete capabilities for both keys and values
  • Sorting functionality with customizable direction
  • Expandable/collapsible nested objects and arrays
  • JSON file import functionality
  • Multiple icon packages support (Basic, Font Awesome, Material Design)
  • Fully customizable table styling
  • Two-way data binding support
  • Type-safe with TypeScript

Installation

Install the library using npm or yarn:

# Using npm
npm install --save ngx-json-table

# Using yarn
yarn add ngx-json-table

Basic Usage

  1. Import the NgxJsonTableModule in your application module:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgxJsonTableModule } from 'ngx-json-table';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, NgxJsonTableModule],
  bootstrap: [AppComponent],
})
export class AppModule {}
  1. Use the component in your template:
<!-- Basic usage with default settings -->
<table ngx-json-table [data]="yourJsonData"></table>

<!-- With custom settings -->
<table ngx-json-table [data]="yourJsonData" [settings]="tableSettings"></table>
  1. Define your data and settings in your component:
import { Component } from '@angular/core';
import { Settings, JsonValue } from 'ngx-json-table';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
})
export class AppComponent {
  // Your JSON data
  yourJsonData: JsonValue = {
    product: 'NGX JSON Table',
    version: 1.0,
    features: ['Sorting', 'Editing', 'Nested objects'],
    configuration: {
      sortable: true,
      editable: true,
    },
  };

  // Optional settings
  tableSettings: Settings = {
    sortable: true,
    sortDirection: 'asc',
    expandAll: true,
    loadFromFile: true,
    options: {
      add: true,
      edit: {
        key: true,
        value: true,
      },
      delete: true,
    },
  };
}

Configuration Options

The Settings interface provides various options to customize your table:

export type Settings = {
  // Customize the key column
  key?: {
    headerText?: string; // Default: "Key"
    width?: string; // Default: "40%"
  };

  // Customize the value column
  value?: {
    headerText?: string; // Default: "Value"
    width?: string; // Default: "60%"
  };

  // Enable/disable operations
  options?: {
    add?: boolean; // Enable adding new properties
    edit?: {
      key?: boolean; // Enable editing keys
      value?: boolean; // Enable editing values
    };
    delete?: boolean; // Enable deleting properties
  };

  sortable?: boolean; // Enable sorting
  sortDirection?: 'asc' | 'desc'; // Default sort direction
  expandAll?: boolean; // Expand all nested objects by default
  loadFromFile?: boolean; // Show button to load JSON from file

  // Icon package to use
  iconPackage?: 'basic' | 'font-awesome' | 'material-design';
};

Events

The component provides events to react to data changes:

<table ngx-json-table [data]="data" (dataChange)="onDataChange($event)"></table>
onDataChange(newData: JsonValue) {
  console.log('Data changed:', newData);
  // Update your application state or perform other actions
}

Icon Packages

ngx-json-table supports three icon packages out of the box:

  1. Basic: Default package using HTML entities (no external dependencies)
  2. Font Awesome: Requires Font Awesome to be installed
  3. Material Design: Requires Material Icons to be installed

To use a specific icon package:

tableSettings: Settings = {
  iconPackage: 'material-design',
  // other settings...
};

Complete Example

Here's a complete example with all features enabled:

import { Component } from '@angular/core';
import { Settings, JsonValue } from 'ngx-json-table';

@Component({
  selector: 'app-example',
  template: `
    <table
      ngx-json-table
      [data]="data"
      [settings]="settings"
      (dataChange)="onDataChange($event)"></table>
  `,
})
export class ExampleComponent {
  settings: Settings = {
    key: {
      headerText: 'Property',
      width: '30%',
    },
    value: {
      headerText: 'Data',
      width: '70%',
    },
    sortable: true,
    sortDirection: 'asc',
    expandAll: true,
    loadFromFile: true,
    iconPackage: 'font-awesome',
    options: {
      add: true,
      edit: {
        key: true,
        value: true,
      },
      delete: true,
    },
  };

  data: JsonValue = {
    // Your JSON data here...
  };

  onDataChange(newData: JsonValue) {
    console.log('Data updated:', newData);
    this.data = newData;
  }
}

Browser Support

ngx-json-table supports all major browsers and platforms, including:

  • Chrome, Firefox, Edge, Safari, Opera
  • Mobile browsers (iOS, Android)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT license.