
Research
/Security News
Intercom’s npm Package Compromised in Ongoing Mini Shai-Hulud Worm Attack
Compromised intercom-client@7.0.4 npm package is tied to the ongoing Mini Shai-Hulud worm attack targeting developer and CI/CD secrets.
json-compact
Advanced tools
Create a downsized json file from tabular data, ie [{...},{...}] Optimized for GPT/LLM processing.
JSONcompact is a TypeScript/JavaScript library designed to convert complex JSON data into a compact, tabular format. This format is particularly suitable for processing and analysis with AI models like GPT-3. The library also provides functionality to revert this compacted data back to its original form. It offers an optional feature to round numerical values to a specified number of decimal places. The library is useful in scenarios where you need to minimize JSON size without losing the essence and structure of the data. You can expect a reduction in token size of >40% for larger data sets.
npm install json-compact
import JSONcompact from 'json-compact';
const originalData = [
{ name: "Alice", age: 30.123, occupation: "Engineer" },
{ name: "Bob", age: 25.456, occupation: "Designer" }
];
// Compact without rounding
const compacted = JSONcompact.compact(originalData);
console.log(compacted);
// Compact with rounding to 2 decimal places
const compactedRounded = JSONcompact.compact(originalData, undefined, 2);
console.log(compactedRounded);
const expandedData = JSONcompact.expand(compacted);
console.log(expandedData);
The library also supports compacting and expanding JSON strings directly.
const jsonDataString = JSON.stringify(originalData);
const compactedString = JSONcompact.compactedJSON(jsonDataString);
console.log(compactedString);
const expandedString = JSONcompact.expandedJSON(compactedString);
console.log(expandedString);
JSONcompact.compact(data, [description], [roundToDecimalPlaces])Compacts an array of data objects or a JSON string into a tabular format.
data: An array of objects or a JSON string representing the data to be compacted.description: Optional. Custom description for the compacted data.roundToDecimalPlaces: Optional. Number of decimal places to round numerical values to. If not provided, numbers are not rounded.JSONcompact.expand(data)Expands the compacted data back into its original format.
data: The compacted data object or a string in the compacted JSON format.Contributions are welcome! Please feel free to submit a pull request or open issues to improve the library.
This project is licensed under the MIT License.
FAQs
Create a downsized json file from tabular data, ie [{...},{...}] Optimized for GPT/LLM processing.
We found that json-compact demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Research
/Security News
Compromised intercom-client@7.0.4 npm package is tied to the ongoing Mini Shai-Hulud worm attack targeting developer and CI/CD secrets.

Research
Socket detected a malicious supply chain attack on PyPI package lightning versions 2.6.2 and 2.6.3, which execute credential-stealing malware on import.

Research
A brand-squatted TanStack npm package used postinstall scripts to steal .env files and exfiltrate developer secrets to an attacker-controlled endpoint.