toon-formatter 1.1.1 → 2.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,95 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.0.0] - 2025-12-08
9
+
10
+ ### Added
11
+ - **🔐 End-to-End Encryption Support**
12
+ - New `Encryptor` class with AES-256-GCM, XOR, and Base64 algorithms
13
+ - `Encryptor.generateKey()` static method for secure key generation
14
+ - Instance-based `ToonConverter` API with encryption support
15
+ - Four conversion modes: `no_encryption`, `middleware`, `ingestion`, `export`
16
+ - Comprehensive encryption documentation and examples
17
+
18
+ - **New Features**
19
+ - `returnJson` parameter for `toJson()` and `toJsonAsync()` methods
20
+ - Support for encrypted data pipelines
21
+ - Key rotation capabilities
22
+ - Authentication tag validation (AES-256-GCM)
23
+
24
+ - **Testing**
25
+ - 33 new encryption unit tests
26
+ - 32 new integration tests
27
+ - 8 backward compatibility tests
28
+ - Total: 96 tests (all passing)
29
+
30
+ - **Documentation**
31
+ - Complete encryption guide in README
32
+ - Security best practices
33
+ - Real-world examples
34
+ - Migration guide
35
+ - API reference for Encryptor and ToonConverter
36
+
37
+ ### Changed
38
+ - `ToonConverter` now supports both static methods (backward compatible) and instance methods (with encryption)
39
+ - `toonToJsonSync()` and `toonToJson()` now accept optional `returnJson` parameter
40
+ - Updated package description to mention encryption support
41
+ - Enhanced package keywords for better discoverability
42
+
43
+ ### Backward Compatibility
44
+ - ✅ All existing static methods work exactly as before
45
+ - ✅ Default behavior unchanged (`returnJson=false`)
46
+ - ✅ No breaking changes for existing users
47
+ - ✅ Full backward compatibility maintained
48
+
49
+ ### Security
50
+ - AES-256-GCM encryption with random IV per operation
51
+ - Authentication tag prevents data tampering
52
+ - Secure key generation using Node.js crypto
53
+ - No external cryptographic dependencies
54
+
55
+ ## [1.1.1] - Previous Release
56
+
57
+ ### Features
58
+ - JSON, YAML, XML, CSV conversion support
59
+ - Mixed text extraction
60
+ - Synchronous and asynchronous APIs
61
+ - TOON validation
62
+ - Comprehensive test suite
63
+
64
+ ---
65
+
66
+ ## Migration Guide
67
+
68
+ ### From v1.x to v2.0
69
+
70
+ **No changes required!** Version 2.0 is fully backward compatible.
71
+
72
+ **To use new encryption features:**
73
+
74
+ ```javascript
75
+ // Old code (still works)
76
+ import { ToonConverter } from 'toon-formatter';
77
+ const toon = ToonConverter.fromJson(data);
78
+
79
+ // New code (with encryption)
80
+ import { ToonConverter, Encryptor } from 'toon-formatter';
81
+ const key = Encryptor.generateKey();
82
+ const encryptor = new Encryptor(key, 'aes-256-gcm');
83
+ const converter = new ToonConverter(encryptor);
84
+ const encrypted = converter.fromJson(data, { conversionMode: 'export' });
85
+ ```
86
+
87
+ **To use returnJson parameter:**
88
+
89
+ ```javascript
90
+ // Returns object (default, backward compatible)
91
+ const obj = ToonConverter.toJson(toonString);
92
+
93
+ // Returns JSON string (new feature)
94
+ const jsonString = ToonConverter.toJson(toonString, true);
95
+ ```
package/README.md CHANGED
@@ -1,9 +1,14 @@
1
1
  # 🚀 TOON Converter
2
2
 
3
- A lightweight, zero-dependency* library to convert between **TOON** (Token-Oriented Object Notation) and popular data formats (JSON, YAML, XML, CSV).
3
+ A lightweight library to convert between **TOON** (Token-Oriented Object Notation) and popular data formats (JSON, YAML, XML, CSV).
4
4
 
5
5
  **Reduce your LLM token costs by up to 40%** using the TOON format!
6
6
 
7
+ - **Documentation**: https://toonformatter.net/docs.html?package=toon-formatter
8
+ - **Source Code**: https://github.com/ankitpal181/toon-formatter-lib
9
+ - **Bug Reports**: https://github.com/ankitpal181/toon-formatter-lib/issues
10
+ - **POC Tool**: https://toonformatter.net/
11
+
7
12
  \* *Only external dependencies: `js-yaml` and `papaparse` for YAML and CSV parsing*
8
13
 
9
14
  ---
@@ -288,9 +293,374 @@ console.log(converted);
288
293
  // price: 29.99
289
294
  ```
290
295
 
296
+ ```
297
+
298
+ ---
299
+
300
+ ## 🔐 Encryption Support
301
+
302
+ **NEW in v2.0.0**: The TOON Converter now supports end-to-end encryption for secure data transmission and storage!
303
+
304
+ ### Overview
305
+
306
+ The encryption feature allows you to:
307
+ - **Encrypt data before transmission** to protect sensitive information
308
+ - **Store encrypted TOON data** securely
309
+ - **Process encrypted data** without exposing plaintext
310
+ - **Support multiple encryption algorithms**: AES-256-GCM, XOR, Base64
311
+
312
+ ### Quick Start with Encryption
313
+
314
+ ```javascript
315
+ import { ToonConverter, Encryptor } from 'toon-formatter';
316
+
317
+ // 1. Generate a secure encryption key
318
+ const key = Encryptor.generateKey(); // 32-byte key for AES-256-GCM
319
+
320
+ // 2. Create an encryptor
321
+ const encryptor = new Encryptor(key, 'aes-256-gcm');
322
+
323
+ // 3. Create a converter with encryption support
324
+ const converter = new ToonConverter(encryptor);
325
+
326
+ // 4. Convert and encrypt data
327
+ const data = { user: "Alice", role: "admin" };
328
+ const encryptedToon = converter.fromJson(data, {
329
+ conversionMode: 'export'
330
+ });
331
+
332
+ console.log(encryptedToon); // Encrypted string
333
+
334
+ // 5. Decrypt and convert back
335
+ const decrypted = encryptor.decrypt(encryptedToon);
336
+ console.log(decrypted); // Plain TOON string
337
+ ```
338
+
339
+ ### Encryption Algorithms
340
+
341
+ #### AES-256-GCM (Recommended)
342
+ High-security authenticated encryption with Galois/Counter Mode.
343
+
344
+ ```javascript
345
+ const key = Encryptor.generateKey(); // Generates 32-byte key
346
+ const encryptor = new Encryptor(key, 'aes-256-gcm');
347
+ ```
348
+
349
+ **Features:**
350
+ - ✅ Military-grade encryption
351
+ - ✅ Authentication tag prevents tampering
352
+ - ✅ Random IV for each encryption
353
+ - ✅ No external dependencies (uses Node.js crypto)
354
+
355
+ #### XOR Cipher
356
+ Simple obfuscation (not cryptographically secure).
357
+
358
+ ```javascript
359
+ const encryptor = new Encryptor('my-secret-key', 'xor');
360
+ ```
361
+
362
+ **Use cases:**
363
+ - Quick obfuscation
364
+ - Non-sensitive data
365
+ - Deterministic encryption
366
+
367
+ #### Base64 Encoding
368
+ Simple encoding (not encryption).
369
+
370
+ ```javascript
371
+ const encryptor = new Encryptor(null, 'base64');
372
+ ```
373
+
374
+ **Use cases:**
375
+ - Data encoding
376
+ - Testing
377
+ - Non-sensitive transformations
378
+
379
+ ### Conversion Modes
380
+
381
+ The encryption system supports **4 conversion modes** for different data flow scenarios:
382
+
383
+ #### 1. `no_encryption` (Default)
384
+ No encryption applied - standard conversion.
385
+
386
+ ```javascript
387
+ const converter = new ToonConverter(encryptor);
388
+ const toon = converter.fromJson(data); // Plain TOON
389
+ ```
390
+
391
+ #### 2. `middleware` Mode
392
+ **Encrypted → Encrypted** (Decrypt → Convert → Re-encrypt)
393
+
394
+ Perfect for middleware services that need to convert format without exposing data.
395
+
396
+ ```javascript
397
+ // Input: Encrypted JSON
398
+ const encryptedJson = '...'; // From client
399
+
400
+ // Convert to encrypted TOON (never see plaintext)
401
+ const encryptedToon = converter.fromJson(encryptedJson, {
402
+ conversionMode: 'middleware'
403
+ });
404
+
405
+ // Output: Encrypted TOON (can be stored or forwarded)
406
+ ```
407
+
408
+ **Use case:** API gateway converting encrypted client data to encrypted storage format.
409
+
410
+ #### 3. `ingestion` Mode
411
+ **Encrypted → Plain** (Decrypt → Convert)
412
+
413
+ For ingesting encrypted data into your system.
414
+
415
+ ```javascript
416
+ // Input: Encrypted JSON from external source
417
+ const encryptedJson = '...';
418
+
419
+ // Convert to plain TOON for processing
420
+ const plainToon = converter.fromJson(encryptedJson, {
421
+ conversionMode: 'ingestion'
422
+ });
423
+
424
+ // Output: Plain TOON (ready for processing)
425
+ ```
426
+
427
+ **Use case:** Receiving encrypted data from clients and converting to internal format.
428
+
429
+ #### 4. `export` Mode
430
+ **Plain → Encrypted** (Convert → Encrypt)
431
+
432
+ For exporting data securely.
433
+
434
+ ```javascript
435
+ // Input: Plain JSON data
436
+ const data = { user: "Alice", role: "admin" };
437
+
438
+ // Convert and encrypt for transmission
439
+ const encryptedToon = converter.fromJson(data, {
440
+ conversionMode: 'export'
441
+ });
442
+
443
+ // Output: Encrypted TOON (safe to transmit)
444
+ ```
445
+
446
+ **Use case:** Sending data to external systems or clients securely.
447
+
448
+ ### Real-World Example: Secure API Pipeline
449
+
450
+ ```javascript
451
+ import { ToonConverter, Encryptor } from 'toon-formatter';
452
+
453
+ // Setup (same key on client and server)
454
+ const key = Encryptor.generateKey();
455
+ const encryptor = new Encryptor(key, 'aes-256-gcm');
456
+
457
+ // CLIENT SIDE
458
+ // ============
459
+ const clientConverter = new ToonConverter(encryptor);
460
+
461
+ // 1. User submits sensitive data
462
+ const userData = {
463
+ ssn: "123-45-6789",
464
+ creditCard: "4111-1111-1111-1111",
465
+ email: "alice@example.com"
466
+ };
467
+
468
+ // 2. Encrypt before sending
469
+ const encryptedPayload = encryptor.encrypt(JSON.stringify(userData));
470
+
471
+ // 3. Send to server
472
+ await fetch('/api/user', {
473
+ method: 'POST',
474
+ body: encryptedPayload
475
+ });
476
+
477
+ // SERVER SIDE (Middleware)
478
+ // =========================
479
+ const serverConverter = new ToonConverter(encryptor);
480
+
481
+ // 4. Receive encrypted data
482
+ const encryptedJson = await request.text();
483
+
484
+ // 5. Convert to encrypted TOON for storage (middleware mode)
485
+ const encryptedToon = serverConverter.fromJson(encryptedJson, {
486
+ conversionMode: 'middleware'
487
+ });
488
+
489
+ // 6. Store encrypted TOON in database
490
+ await db.save(encryptedToon);
491
+
492
+ // SERVER SIDE (Processing)
493
+ // =========================
494
+ // 7. Retrieve encrypted TOON
495
+ const storedToon = await db.get(userId);
496
+
497
+ // 8. Convert back to plain JSON for processing (ingestion mode)
498
+ const plainData = serverConverter.toJson(storedToon, {
499
+ conversionMode: 'ingestion',
500
+ returnJson: true
501
+ });
502
+
503
+ // 9. Process data
504
+ const user = JSON.parse(plainData);
505
+ console.log(user.email); // alice@example.com
506
+ ```
507
+
508
+ ### Working with `returnJson` Parameter
509
+
510
+ By default, `toJson()` returns a JavaScript object. For encryption modes, you need a string. Use `returnJson: true`:
511
+
512
+ ```javascript
513
+ // Returns object (default)
514
+ const obj = converter.toJson(toonString);
515
+ console.log(obj); // { name: "Alice" }
516
+
517
+ // Returns JSON string (for encryption)
518
+ const jsonString = converter.toJson(toonString, { returnJson: true });
519
+ console.log(jsonString); // '{"name":"Alice"}'
520
+
521
+ // With encryption
522
+ const encrypted = converter.toJson(toonString, {
523
+ conversionMode: 'export',
524
+ returnJson: true // Required for encryption!
525
+ });
526
+ ```
527
+
528
+ ### Key Management Best Practices
529
+
530
+ #### 🔑 Generating Keys
531
+
532
+ ```javascript
533
+ // Generate a secure random key
534
+ const key = Encryptor.generateKey();
535
+
536
+ // Store as Base64 (e.g., in environment variables)
537
+ const keyBase64 = key.toString('base64');
538
+ process.env.ENCRYPTION_KEY = keyBase64;
539
+
540
+ // Load from storage
541
+ const loadedKey = Buffer.from(process.env.ENCRYPTION_KEY, 'base64');
542
+ const encryptor = new Encryptor(loadedKey, 'aes-256-gcm');
543
+ ```
544
+
545
+ #### 🔒 Security Best Practices
546
+
547
+ 1. **Never hardcode keys** in source code
548
+ 2. **Use environment variables** or secure key management systems
549
+ 3. **Rotate keys periodically** for long-term security
550
+ 4. **Use AES-256-GCM** for production (not XOR or Base64)
551
+ 5. **Protect keys at rest** with proper file permissions
552
+ 6. **Use HTTPS** for transmitting encrypted data
553
+ 7. **Implement key rotation** strategy
554
+
555
+ #### 🔄 Key Rotation Example
556
+
557
+ ```javascript
558
+ // Old system
559
+ const oldKey = Buffer.from(process.env.OLD_KEY, 'base64');
560
+ const oldEncryptor = new Encryptor(oldKey, 'aes-256-gcm');
561
+
562
+ // New system
563
+ const newKey = Encryptor.generateKey();
564
+ const newEncryptor = new Encryptor(newKey, 'aes-256-gcm');
565
+
566
+ // Migrate data
567
+ const encryptedData = await db.getAllEncrypted();
568
+
569
+ for (const item of encryptedData) {
570
+ // Decrypt with old key
571
+ const plaintext = oldEncryptor.decrypt(item.data);
572
+
573
+ // Re-encrypt with new key
574
+ const reEncrypted = newEncryptor.encrypt(plaintext);
575
+
576
+ // Update database
577
+ await db.update(item.id, reEncrypted);
578
+ }
579
+
580
+ // Update environment variable
581
+ process.env.ENCRYPTION_KEY = newKey.toString('base64');
582
+ ```
583
+
584
+ ### Error Handling
585
+
586
+ ```javascript
587
+ try {
588
+ const encrypted = encryptor.encrypt(data);
589
+ const decrypted = encryptor.decrypt(encrypted);
590
+ } catch (error) {
591
+ if (error.message.includes('decryption failed')) {
592
+ console.error('Wrong key or tampered data');
593
+ } else if (error.message.includes('Invalid encrypted data format')) {
594
+ console.error('Corrupted ciphertext');
595
+ } else {
596
+ console.error('Encryption error:', error.message);
597
+ }
598
+ }
599
+ ```
600
+
601
+ ### Async Encryption
602
+
603
+ All encryption operations work with async methods:
604
+
605
+ ```javascript
606
+ const converter = new ToonConverter(encryptor);
607
+
608
+ // Async conversion with encryption
609
+ const encrypted = await converter.fromJsonAsync(data, {
610
+ conversionMode: 'export'
611
+ });
612
+
613
+ const decrypted = await converter.toJsonAsync(encrypted, {
614
+ conversionMode: 'ingestion',
615
+ returnJson: true
616
+ });
617
+ ```
618
+
619
+ ### Migration Guide
620
+
621
+ #### From Static to Instance API
622
+
623
+ **Before (no encryption):**
624
+ ```javascript
625
+ import { ToonConverter } from 'toon-formatter';
626
+
627
+ const toon = ToonConverter.fromJson(data);
628
+ const json = ToonConverter.toJson(toon);
629
+ ```
630
+
631
+ **After (with encryption):**
632
+ ```javascript
633
+ import { ToonConverter, Encryptor } from 'toon-formatter';
634
+
635
+ // Create encryptor
636
+ const key = Encryptor.generateKey();
637
+ const encryptor = new Encryptor(key, 'aes-256-gcm');
638
+
639
+ // Create converter instance
640
+ const converter = new ToonConverter(encryptor);
641
+
642
+ // Use instance methods
643
+ const encrypted = converter.fromJson(data, { conversionMode: 'export' });
644
+ const plain = converter.toJson(encrypted, { conversionMode: 'ingestion' });
645
+ ```
646
+
647
+ **Note:** Static methods still work for backward compatibility (no encryption).
648
+
649
+ ### Performance Considerations
650
+
651
+ - **AES-256-GCM**: ~0.5-1ms per operation (recommended)
652
+ - **XOR**: ~0.1ms per operation (fast but insecure)
653
+ - **Base64**: ~0.05ms per operation (fastest, no security)
654
+
655
+ For high-throughput applications, consider:
656
+ - Batch processing
657
+ - Caching decrypted data (with proper TTL)
658
+ - Using middleware mode to avoid double encryption/decryption
659
+
291
660
  ---
292
661
 
293
- ## �📚 API Reference
662
+ ## 📚 API Reference
663
+
294
664
 
295
665
  ### JSON Converters
296
666
 
@@ -335,25 +705,27 @@ Converts JSON data to TOON format (asynchronous).
335
705
 
336
706
  **Returns:** `Promise<string>` - TOON formatted string
337
707
 
338
- #### `toonToJsonSync(toonString)`
708
+ #### `toonToJsonSync(toonString, returnJson?)`
339
709
  Converts TOON string to JSON (synchronous).
340
710
 
341
711
  **Supports:** ❌ Pure TOON data only (no mixed text)
342
712
 
343
713
  **Parameters:**
344
714
  - `toonString` (string): TOON formatted string
715
+ - `returnJson` (boolean, optional): If `true`, returns JSON string; if `false` (default), returns object
345
716
 
346
- **Returns:** `any` - Parsed JSON data
717
+ **Returns:** `any | string` - Parsed JSON data (object by default, string if `returnJson=true`)
347
718
 
348
- #### `toonToJson(toonString)`
719
+ #### `toonToJson(toonString, returnJson?)`
349
720
  Converts TOON string to JSON (asynchronous).
350
721
 
351
722
  **Supports:** ❌ Pure TOON data only (no mixed text)
352
723
 
353
724
  **Parameters:**
354
725
  - `toonString` (string): TOON formatted string
726
+ - `returnJson` (boolean, optional): If `true`, returns JSON string; if `false` (default), returns object
355
727
 
356
- **Returns:** `Promise<any>` - Parsed JSON data
728
+ **Returns:** `Promise<any | string>` - Parsed JSON data (object by default, string if `returnJson=true`)
357
729
 
358
730
  ---
359
731
 
@@ -554,6 +926,166 @@ Validates a TOON string for syntax and structural correctness (asynchronous).
554
926
 
555
927
  ---
556
928
 
929
+
930
+ ---
931
+
932
+ ### Encryptor Class
933
+
934
+ The `Encryptor` class provides encryption and decryption capabilities.
935
+
936
+ #### `new Encryptor(key, algorithm)`
937
+ Creates a new Encryptor instance.
938
+
939
+ **Parameters:**
940
+ - `key` (Buffer | string | null): Encryption key
941
+ - For `aes-256-gcm`: 32-byte Buffer (use `Encryptor.generateKey()`)
942
+ - For `xor`: String or Buffer
943
+ - For `base64`: null (no key needed)
944
+ - `algorithm` (string): Encryption algorithm - `'aes-256-gcm'`, `'xor'`, or `'base64'`
945
+
946
+ **Example:**
947
+ ```javascript
948
+ // AES-256-GCM (recommended)
949
+ const key = Encryptor.generateKey();
950
+ const encryptor = new Encryptor(key, 'aes-256-gcm');
951
+
952
+ // XOR
953
+ const xorEncryptor = new Encryptor('my-secret-key', 'xor');
954
+
955
+ // Base64
956
+ const base64Encryptor = new Encryptor(null, 'base64');
957
+ ```
958
+
959
+ #### `Encryptor.generateKey()`
960
+ Static method to generate a secure 32-byte encryption key for AES-256-GCM.
961
+
962
+ **Returns:** `Buffer` - 32-byte random key
963
+
964
+ **Example:**
965
+ ```javascript
966
+ const key = Encryptor.generateKey();
967
+ console.log(key.length); // 32
968
+
969
+ // Store as Base64
970
+ const keyBase64 = key.toString('base64');
971
+ process.env.ENCRYPTION_KEY = keyBase64;
972
+
973
+ // Load from Base64
974
+ const loadedKey = Buffer.from(process.env.ENCRYPTION_KEY, 'base64');
975
+ ```
976
+
977
+ #### `encryptor.encrypt(data)`
978
+ Encrypts a string.
979
+
980
+ **Parameters:**
981
+ - `data` (string): Plaintext string to encrypt
982
+
983
+ **Returns:** `string` - Encrypted string (hex-encoded for AES-256-GCM and XOR, Base64 for base64)
984
+
985
+ **Throws:** Error if data is not a string or key is missing (for AES/XOR)
986
+
987
+ **Example:**
988
+ ```javascript
989
+ const encrypted = encryptor.encrypt('Hello, World!');
990
+ console.log(encrypted); // Hex string (AES-256-GCM)
991
+ ```
992
+
993
+ #### `encryptor.decrypt(encryptedData)`
994
+ Decrypts an encrypted string.
995
+
996
+ **Parameters:**
997
+ - `encryptedData` (string): Encrypted string
998
+
999
+ **Returns:** `string` - Decrypted plaintext
1000
+
1001
+ **Throws:** Error if decryption fails, wrong key, or tampered data
1002
+
1003
+ **Example:**
1004
+ ```javascript
1005
+ const decrypted = encryptor.decrypt(encrypted);
1006
+ console.log(decrypted); // 'Hello, World!'
1007
+ ```
1008
+
1009
+ ---
1010
+
1011
+ ### ToonConverter Class (with Encryption)
1012
+
1013
+ The `ToonConverter` class now supports both static methods (backward compatible) and instance methods (with encryption).
1014
+
1015
+ #### `new ToonConverter(encryptor?)`
1016
+ Creates a new ToonConverter instance.
1017
+
1018
+ **Parameters:**
1019
+ - `encryptor` (Encryptor | null, optional): Encryptor instance for encryption support
1020
+
1021
+ **Example:**
1022
+ ```javascript
1023
+ // Without encryption
1024
+ const converter = new ToonConverter();
1025
+
1026
+ // With encryption
1027
+ const key = Encryptor.generateKey();
1028
+ const encryptor = new Encryptor(key, 'aes-256-gcm');
1029
+ const converter = new ToonConverter(encryptor);
1030
+ ```
1031
+
1032
+ #### Instance Methods with Encryption Support
1033
+
1034
+ All instance methods accept an `options` object with:
1035
+ - `conversionMode` (string): `'no_encryption'` (default), `'middleware'`, `'ingestion'`, or `'export'`
1036
+ - `returnJson` (boolean, for `toJson` methods): If `true`, returns JSON string; if `false` (default), returns object
1037
+
1038
+ **Example:**
1039
+ ```javascript
1040
+ // fromJson with encryption
1041
+ const encrypted = converter.fromJson(data, {
1042
+ conversionMode: 'export'
1043
+ });
1044
+
1045
+ // toJson with encryption and JSON string output
1046
+ const jsonString = converter.toJson(toonString, {
1047
+ conversionMode: 'ingestion',
1048
+ returnJson: true
1049
+ });
1050
+
1051
+ // fromYaml with middleware mode
1052
+ const encryptedToon = converter.fromYaml(encryptedYaml, {
1053
+ conversionMode: 'middleware'
1054
+ });
1055
+ ```
1056
+
1057
+ **Available instance methods:**
1058
+ - `fromJson(data, options?)` / `fromJsonAsync(data, options?)`
1059
+ - `toJson(toonString, options?)` / `toJsonAsync(toonString, options?)`
1060
+ - `fromYaml(yamlString, options?)` / `fromYamlAsync(yamlString, options?)`
1061
+ - `toYaml(toonString, options?)` / `toYamlAsync(toonString, options?)`
1062
+ - `fromXml(xmlString, options?)` / `fromXmlAsync(xmlString, options?)`
1063
+ - `toXml(toonString, options?)` / `toXmlAsync(toonString, options?)`
1064
+ - `fromCsv(csvString, options?)` / `fromCsvAsync(csvString, options?)`
1065
+ - `toCsv(toonString, options?)` / `toCsvAsync(toonString, options?)`
1066
+ - `validate(toonString)` / `validateAsync(toonString)`
1067
+
1068
+ #### Static Methods (Backward Compatible)
1069
+
1070
+ Static methods work exactly as before, with no encryption support:
1071
+
1072
+ ```javascript
1073
+ // Static usage (no encryption)
1074
+ const toon = ToonConverter.fromJson(data);
1075
+ const json = ToonConverter.toJson(toon);
1076
+
1077
+ // Static with returnJson parameter
1078
+ const jsonString = ToonConverter.toJson(toon, true);
1079
+ ```
1080
+
1081
+ **Note:** For `toJson` and `toJsonAsync` static methods, you can pass `returnJson` as the second parameter:
1082
+ ```javascript
1083
+ ToonConverter.toJson(toonString, returnJson?)
1084
+ ToonConverter.toJsonAsync(toonString, returnJson?)
1085
+ ```
1086
+
1087
+ ---
1088
+
557
1089
  ## 🎨 TOON Format Guide
558
1090
 
559
1091
  ### Primitives