[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Type](https://evolu.dev/docs/api-reference/common/Type) › createIdFromString

```ts
function createIdFromString<B>(
  value: string,
): [B] extends [never] ? string & Brand<"Id"> : string & Brand<"Id"> & Brand<B>;
```

Defined in: [packages/common/src/Type.ts:1809](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Type.ts#L1809)

Creates an [Id](https://evolu.dev/docs/api-reference/common/Type/variables/Id) from a string using SHA-256.

When integrating with external systems that use different ID formats, use
this function to convert external IDs into valid Evolu IDs.

In Evolu's CRDT, the ID serves as the unique identifier for conflict
resolution across distributed clients. When multiple clients create records
with the same external identifier, they must resolve to the same Evolu ID to
ensure data consistency.

### Example

```ts
// Both clients will generate the same ID
const id1 = createIdFromString("user-api-123");
const id2 = createIdFromString("user-api-123");
console.log(id1 === id2); // true

upsert("todo", {
  id: createIdFromString("external-todo-456"),
  title: "Synced from external system",
});
```

**Important**: This transformation uses the first 16 bytes of SHA-256 hash of
the string bytes, therefore it's not possible to recover the original
external string from the generated [Id](https://evolu.dev/docs/api-reference/common/Type/variables/Id). If you need to preserve the
original external ID, store it in a separate column.