We develop the theory of Krull dimension for S4-algebras and Heyting algebras. This leads to the concept of modal Krull dimension for topological spaces. We compare modal Krull dimension to other well-known dimension functions, and show that it can detect differences between topological spaces that Krull dimension is unable to detect. We prove that for a T1-space to have a finite modal Krull dimension can be described by an appropriate generalization of the well-known concept of a nodec space. This, in turn, can be described by modal formulas zemn which generalize the well-known Zeman formula zem. We show that the modal logic S4.Zn := S4 + zemn is the basic modal logic of T1-spaces of modal Krull dimension ≤ n, and we construct a countable dense-in-itself ω-resolvable Tychonoff space Zn of modal Krull dimension n such that S4.Zn is complete with respect to Zn. This yields a version of the McKinsey-Tarski theorem for S4.Zn. We also show that no logic in the interval [S4n+1S4.Zn) is complete with respect to any class of T1-spaces.