webidl2wit - WebIDL to wit converter

May 13, 2026 · View on GitHub

Warning

This project is a Work In Progress ("WIP")

This project converts WebIDL to WebAssembly Interface Types ("WIT"), enabling WebAssembly components to interact with interfaces (most importantly browser primitives) defined via WebIDL.

Usage

webidl2wit can be used as a library from your project:

webidl2wit = "0.1.0"

webidl2wit can also be used as a CLI, via the workspace member project webidl2wit-cli:

cargo install webidl2wit-cli

Type conversions

This section lists the type conversions between WebIDL and WIT, as implemented by webidl2wit:

WebIDL typewit type
any
undefinedjust leave it out
booleanbool
bytes8
octetu8
shorts16
unsigned shortu16
longs32
unsigned longu32
long longs64
unsigned long longu64
floatf32
unrestricted floatf32
doublef64
unrestricted doublef64
bigint
DOMStringstring
ByteStringstring
USVStringstring
object
symbol
interfaceresource or interface
callback interface
dictionaryrecord
enumenum
callbackfunc
constructorconstructor
T? (optional)option<T>
sequence<T>list<T>
record<K, V>A custom resource
Promise<T>future<T>
or (union)variant
Buffer types (e.g. Int8Array)A custom resource
FrozenArray<T>list<T>
ObservableArray<T>
setlike<T>Add set methods
maplike<K, V>map<K, V>
namespaceresource or interface
typedeftype
constA getter
EventHandlerstream

❓ = Not yet sure how to deal with this type.