צרו ממשקי TypeScript מדוגמת JSON, עם טיפוסים מקוננים, מערכים ושדות אופציונליים. פועל בדפדפן שלכם.
כיצד להשתמש בJSON ל-TS
הדביקו אובייקט או מערך JSON.
אופציונלית הגדירו את שם ממשק השורש.
העתיקו את ממשקי ה-TypeScript שנוצרו.
This is a JSON to TypeScript generator that infers a set of interfaces from an example JSON object or array, so you can paste an API response and get ready-to-use types instead of writing them by hand.
It is a big time-saver when you are consuming an API or a config file: paste a response, optionally name the root interface, and copy clean TypeScript straight into your code.
Generation runs entirely in your browser, so your data never leaves your device, which matters when the sample contains real values.
It handles real-world shapes: nested objects become their own named interfaces referenced from the parent, arrays of objects are merged into one interface, and union types are produced where values vary.
When the objects in an array do not all have the same keys, the keys missing from some elements are marked optional with a question mark, which matches how the data actually behaves and keeps the types honest.
One important point: it infers a shape from the single sample you give it, rather than enforcing a schema. If a field is sometimes null or absent in real data but not in your sample, the generated type will not know that, so use a representative example.
שאלות נפוצות
כל אובייקט מקונן הופך לממשק נפרד עם שם, המופנה מההורה שלו, כך שהתוצאה נקייה וניתנת לשימוש חוזר.
מערכים של אובייקטים ממוזגים לממשק אחד, ומפתחות החסרים בחלק מהאיברים מסומנים כאופציונליים. מערכים של פרימיטיבים מעורבים הופכים לטיפוס איבר מסוג union.
לא. הטיפוסים נוצרים כולם בתוך הדפדפן שלכם, כך שהנתונים שלכם לעולם לא עוזבים את המכשיר.
הטמע את הכלי הזה
הוסף את הכלי הזה לאתר שלך. העתק את קטע הקוד שלהלן; הוא מתעדכן אוטומטית.
<iframe src="https://monu.tools/embed/he/json-to-typescript" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>כלים קשורים
עצבו, ייפו ואמתו JSON אונליין עם הודעות שגיאה ברורות עבור קלט לא תקין.
הקטנה ואימות של JSON בדפדפן שלכם, וצפייה בכמה בייטים אתם חוסכים.
המרת JSON ל-CSV ו-CSV חזרה ל-JSON, בשני הכיוונים. בחרו את התו המפריד, טפלו בשדות במרכאות והעתיקו את התוצאה. הכול רץ בדפדפן שלכם.
המרת YAML ל-JSON ו-JSON חזרה ל-YAML, בשני הכיוונים. מאמת תוך כדי המרה ומציג שגיאות ברורות. הכול רץ בדפדפן שלכם.