devpocket.dev

JSON से TypeScript

एक या अधिक JSON samples से TypeScript interfaces और Zod schemas infer करें।

लोकल चलता है
टूल लोड हो रहा है…

इस्तेमाल कैसे करें

JSON object, sample objects की array या newline-delimited JSON objects पेस्ट करें। Root type का नाम दें और TypeScript व Zod output के बीच switch करें।

Array और JSONL samples structurally merge होते हैं: कुछ objects में missing field optional बनता है, conflicting value types unions बनते हैं और nested objects को path से stable names मिलते हैं। Empty arrays में element type infer नहीं हो सकता, इसलिए unknown[] इस्तेमाल होता है।

आम सवाल

Optional fields कैसे पहचाने जाते हैं?

Array items या JSONL samples merge करते समय, same structural level के कम-से-कम एक object में field न हो तो वह optional बनता है।

क्या generated Zod code यहाँ चलता है?

नहीं। टूल केवल source code बनाता है। इसे ऐसे project में कॉपी करें जहाँ Zod installed हो।

मिलते-जुलते टूल