formatarc 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,28 @@
1
1
  # formatarc
2
2
 
3
- Convert JSON, YAML, CSV, Markdown, and HTML from the terminal. No config, no dependencies to manage just pipe or pass your data.
3
+ Convert JSON, YAML, CSV, Markdown, and HTML from the terminal your data never leaves your machine. No config, no telemetry, no upload.
4
4
 
5
- **Web version → [formatarc.com](https://formatarc.com)**
5
+ [![npm version](https://img.shields.io/npm/v/formatarc.svg)](https://www.npmjs.com/package/formatarc)
6
+ [![license: MIT](https://img.shields.io/npm/l/formatarc.svg)](https://github.com/m-naoki-m/formatarc/blob/main/LICENSE)
7
+ [![npm downloads](https://img.shields.io/npm/dm/formatarc.svg)](https://www.npmjs.com/package/formatarc)
8
+
9
+ **Web version → [formatarc.com](https://formatarc.com)** — the same conversions, 100% in your browser, no signup.
10
+
11
+ ## Why formatarc?
12
+
13
+ Most "online JSON / YAML / CSV converters" send the data you paste to a server. In November 2025, security firm watchTowr disclosed that two popular formatter sites (jsonformatter.org and codebeautify.org) had publicly exposed **over 80,000 saved submissions (5 GB+)** through a predictable "Recent Links" URL — including Active Directory credentials, cloud access keys, private keys, CI/CD secrets, JWTs, and full AWS Secrets Manager exports from government, banking, healthcare, and aerospace organizations. ([watchTowr report](https://labs.watchtowr.com/stop-putting-your-passwords-into-random-websites-yes-seriously-you-are-the-problem/))
14
+
15
+ formatarc is built so that can't happen. The CLI runs entirely on your machine, and the [web version](https://formatarc.com) runs entirely in your browser — no upload, no logging, no telemetry, no account.
16
+
17
+ It is not only paste-to-a-server sites, either: in early 2026, a widely used JSON formatter browser extension was reported (on Hacker News and dev.to) to add third-party tracking and checkout-page injection after moving to a closed-source model — a reminder that an installed extension can change behaviour through an automatic update. Background on both risks: [are online converters safe?](https://formatarc.com/en/blog/online-converter-safety/) and [picking a JSON formatter Chrome extension by privacy and permissions](https://formatarc.com/en/blog/chrome-extension-json-formatter/).
18
+
19
+ | | formatarc CLI | formatarc web | Typical online converter | jq / yq / pandoc |
20
+ |---|:---:|:---:|:---:|:---:|
21
+ | Data stays local | ✅ | ✅ | ❌ | ✅ |
22
+ | No signup / no upload | ✅ | ✅ | ⚠️ | ✅ |
23
+ | JSON + YAML + CSV + Markdown + HTML in one tool | ✅ | ✅ | ⚠️ | ❌ |
24
+ | Works offline | ✅ | after first load | ❌ | ✅ |
25
+ | Single install | ✅ | n/a | n/a | ❌ |
6
26
 
7
27
  ## Install
8
28
 
@@ -118,7 +138,9 @@ For a browser-based experience with no signup and no data upload:
118
138
  - JSON Formatter, YAML ↔ JSON, CSV → JSON
119
139
  - CSV → Markdown, Markdown ↔ HTML
120
140
  - Runs entirely in the browser
121
- - Multilingual (English / Japanese)
141
+ - Multilingual (English, Japanese, Spanish, Portuguese)
142
+
143
+ There is also a [Chrome extension](https://formatarc.com/en/blog/chrome-extension-json-formatter/) for popup and right-click conversion — same browser-side processing, no upload.
122
144
 
123
145
  ## License
124
146
 
package/dist/converter.js CHANGED
@@ -128,12 +128,51 @@ const turndownService = (() => {
128
128
  });
129
129
  return service;
130
130
  })();
131
+ // Locate a trailing comma (a comma whose next non-whitespace character is `}`
132
+ // or `]`). String-aware so commas/brackets inside string values are ignored.
133
+ // Returns the comma's 1-based line, or null if there is none.
134
+ function findTrailingCommaLine(input) {
135
+ let inString = false;
136
+ let escape = false;
137
+ for (let i = 0; i < input.length; i++) {
138
+ const ch = input[i];
139
+ if (inString) {
140
+ if (escape)
141
+ escape = false;
142
+ else if (ch === "\\")
143
+ escape = true;
144
+ else if (ch === '"')
145
+ inString = false;
146
+ continue;
147
+ }
148
+ if (ch === '"') {
149
+ inString = true;
150
+ continue;
151
+ }
152
+ if (ch === ",") {
153
+ let j = i + 1;
154
+ while (j < input.length && /\s/.test(input[j]))
155
+ j++;
156
+ if (j < input.length && (input[j] === "}" || input[j] === "]")) {
157
+ return input.slice(0, i + 1).split("\n").length;
158
+ }
159
+ }
160
+ }
161
+ return null;
162
+ }
131
163
  function formatError(err, input, tool) {
132
164
  if (err instanceof YAML.YAMLParseError) {
133
165
  const line = err.linePos?.[0]?.line;
134
166
  return line ? `YAML syntax error near line ${line}.` : "YAML syntax error.";
135
167
  }
136
168
  if (err instanceof Error && err.name === "SyntaxError") {
169
+ // Trailing comma is the most common JSON mistake, and parsers report it at
170
+ // the *following* bracket (often on the next line), not at the comma. Find
171
+ // the comma ourselves and point at its line.
172
+ const trailingCommaLine = findTrailingCommaLine(input);
173
+ if (trailingCommaLine !== null) {
174
+ return `Invalid JSON: remove the trailing comma on line ${trailingCommaLine}.`;
175
+ }
137
176
  const match = err.message.match(/position\s+(\d+)/i);
138
177
  if (match) {
139
178
  const line = input.slice(0, Number(match[1])).split("\n").length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "formatarc",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Convert JSON, YAML, CSV, Markdown, and HTML from the terminal. Browser-based version at formatarc.com.",
5
5
  "keywords": [
6
6
  "json",